home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 September / CHIP Eylül 1996.iso / utils / povray / povsrc.sea / POVSRC / SOURCE / BLOB.C < prev    next >
MacBinary  |  1993-08-10  |  18.3 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
10% dexvert Jesper Olsen Module (music/jesperOlsen) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Tue Aug 10 21:17:48 1993, modified Tue Aug 10 21:17:48 1993, creator 'MPS ', type ASCII, 18023 bytes "BLOB.C" , at 0x46e7 428 bytes resource default (weak)
99% file data default
49% TrID Macintosh plain text (MacBinary) default
33% TrID TTComp archive compressed (bin-4K) default (weak)
16% TrID MacBinary 2 default (weak)
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 06 42 4c 4f 42 2e 43 | 00 00 00 00 00 00 00 00 |..BLOB.C|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 01 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 46 67 00 | 00 01 ac a8 8d f9 3c a8 |.....Fg.|......<.|
|00000060| 8d f9 3c 00 00 08 00 00 | 00 00 00 00 00 00 00 00 |..<.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 91 d1 00 00 |........|........|
|00000080| 2f 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |/*******|********|
|00000090| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000000c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 0d 2a 20 |********|*****.* |
|000000d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 62 | | b|
|000000e0| 6c 6f 62 2e 63 0d 2a 0d | 2a 20 20 54 68 69 73 20 |lob.c.*.|* This |
|000000f0| 6d 6f 64 75 6c 65 20 63 | 6f 6e 74 61 69 6e 73 20 |module c|ontains |
|00000100| 74 68 65 20 63 6f 64 65 | 20 66 6f 72 20 74 68 65 |the code| for the|
|00000110| 20 62 6c 6f 62 20 73 68 | 61 70 65 2e 0d 2a 0d 2a | blob sh|ape..*.*|
|00000120| 20 20 54 68 69 73 20 66 | 69 6c 65 20 77 61 73 20 | This f|ile was |
|00000130| 77 72 69 74 74 65 6e 20 | 62 79 20 41 6c 65 78 61 |written |by Alexa|
|00000140| 6e 64 65 72 20 45 6e 7a | 6d 61 6e 6e 2e 09 48 65 |nder Enz|mann..He|
|00000150| 20 77 72 6f 74 65 20 74 | 68 65 20 63 6f 64 65 20 | wrote t|he code |
|00000160| 66 6f 72 0d 2a 20 20 62 | 6c 6f 62 73 20 61 6e 64 |for.* b|lobs and|
|00000170| 20 67 65 6e 65 72 6f 75 | 73 6c 79 20 70 72 6f 76 | generou|sly prov|
|00000180| 69 64 65 64 20 75 73 20 | 74 68 65 73 65 20 65 6e |ided us |these en|
|00000190| 68 61 6e 63 65 6d 65 6e | 74 73 2e 0d 2a 0d 2a 20 |hancemen|ts..*.* |
|000001a0| 20 66 72 6f 6d 20 50 65 | 72 73 69 73 74 65 6e 63 | from Pe|rsistenc|
|000001b0| 65 20 6f 66 20 56 69 73 | 69 6f 6e 20 52 61 79 74 |e of Vis|ion Rayt|
|000001c0| 72 61 63 65 72 0d 2a 20 | 20 43 6f 70 79 72 69 67 |racer.* | Copyrig|
|000001d0| 68 74 20 31 39 39 33 20 | 50 65 72 73 69 73 74 65 |ht 1993 |Persiste|
|000001e0| 6e 63 65 20 6f 66 20 56 | 69 73 69 6f 6e 20 54 65 |nce of V|ision Te|
|000001f0| 61 6d 0d 2a 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |am.*----|--------|
|00000200| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000210| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000220| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000230| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 0d |--------|-------.|
|00000240| 2a 20 20 4e 4f 54 49 43 | 45 3a 20 54 68 69 73 20 |* NOTIC|E: This |
|00000250| 73 6f 75 72 63 65 20 63 | 6f 64 65 20 66 69 6c 65 |source c|ode file|
|00000260| 20 69 73 20 70 72 6f 76 | 69 64 65 64 20 73 6f 20 | is prov|ided so |
|00000270| 74 68 61 74 20 75 73 65 | 72 73 20 6d 61 79 20 65 |that use|rs may e|
|00000280| 78 70 65 72 69 6d 65 6e | 74 0d 2a 20 20 77 69 74 |xperimen|t.* wit|
|00000290| 68 20 65 6e 68 61 6e 63 | 65 6d 65 6e 74 73 20 74 |h enhanc|ements t|
|000002a0| 6f 20 50 4f 56 2d 52 61 | 79 20 61 6e 64 20 74 6f |o POV-Ra|y and to|
|000002b0| 20 70 6f 72 74 20 74 68 | 65 20 73 6f 66 74 77 61 | port th|e softwa|
|000002c0| 72 65 20 74 6f 20 70 6c | 61 74 66 6f 72 6d 73 20 |re to pl|atforms |
|000002d0| 6f 74 68 65 72 20 0d 2a | 20 20 74 68 61 6e 20 74 |other .*| than t|
|000002e0| 68 6f 73 65 20 73 75 70 | 70 6f 72 74 65 64 20 62 |hose sup|ported b|
|000002f0| 79 20 74 68 65 20 50 4f | 56 2d 52 61 79 20 54 65 |y the PO|V-Ray Te|
|00000300| 61 6d 2e 20 20 54 68 65 | 72 65 20 61 72 65 20 73 |am. The|re are s|
|00000310| 74 72 69 63 74 20 72 75 | 6c 65 73 20 75 6e 64 65 |trict ru|les unde|
|00000320| 72 0d 2a 20 20 77 68 69 | 63 68 20 79 6f 75 20 61 |r.* whi|ch you a|
|00000330| 72 65 20 70 65 72 6d 69 | 74 74 65 64 20 74 6f 20 |re permi|tted to |
|00000340| 75 73 65 20 74 68 69 73 | 20 66 69 6c 65 2e 20 20 |use this| file. |
|00000350| 54 68 65 20 72 75 6c 65 | 73 20 61 72 65 20 69 6e |The rule|s are in|
|00000360| 20 74 68 65 20 66 69 6c | 65 0d 2a 20 20 6e 61 6d | the fil|e.* nam|
|00000370| 65 64 20 50 4f 56 4c 45 | 47 41 4c 2e 44 4f 43 20 |ed POVLE|GAL.DOC |
|00000380| 77 68 69 63 68 20 73 68 | 6f 75 6c 64 20 62 65 20 |which sh|ould be |
|00000390| 64 69 73 74 72 69 62 75 | 74 65 64 20 77 69 74 68 |distribu|ted with|
|000003a0| 20 74 68 69 73 20 66 69 | 6c 65 2e 20 49 66 20 0d | this fi|le. If .|
|000003b0| 2a 20 20 50 4f 56 4c 45 | 47 41 4c 2e 44 4f 43 20 |* POVLE|GAL.DOC |
|000003c0| 69 73 20 6e 6f 74 20 61 | 76 61 69 6c 61 62 6c 65 |is not a|vailable|
|000003d0| 20 6f 72 20 66 6f 72 20 | 6d 6f 72 65 20 69 6e 66 | or for |more inf|
|000003e0| 6f 20 70 6c 65 61 73 65 | 20 63 6f 6e 74 61 63 74 |o please| contact|
|000003f0| 20 74 68 65 20 50 4f 56 | 2d 52 61 79 0d 2a 20 20 | the POV|-Ray.* |
|00000400| 54 65 61 6d 20 43 6f 6f | 72 64 69 6e 61 74 6f 72 |Team Coo|rdinator|
|00000410| 20 62 79 20 6c 65 61 76 | 69 6e 67 20 61 20 6d 65 | by leav|ing a me|
|00000420| 73 73 61 67 65 20 69 6e | 20 43 6f 6d 70 75 53 65 |ssage in| CompuSe|
|00000430| 72 76 65 27 73 20 47 72 | 61 70 68 69 63 73 20 44 |rve's Gr|aphics D|
|00000440| 65 76 65 6c 6f 70 65 72 | 27 73 0d 2a 20 20 46 6f |eveloper|'s.* Fo|
|00000450| 72 75 6d 2e 20 20 54 68 | 65 20 6c 61 74 65 73 74 |rum. Th|e latest|
|00000460| 20 76 65 72 73 69 6f 6e | 20 6f 66 20 50 4f 56 2d | version| of POV-|
|00000470| 52 61 79 20 6d 61 79 20 | 62 65 20 66 6f 75 6e 64 |Ray may |be found|
|00000480| 20 74 68 65 72 65 20 61 | 73 20 77 65 6c 6c 2e 0d | there a|s well..|
|00000490| 2a 0d 2a 20 54 68 69 73 | 20 70 72 6f 67 72 61 6d |*.* This| program|
|000004a0| 20 69 73 20 62 61 73 65 | 64 20 6f 6e 20 74 68 65 | is base|d on the|
|000004b0| 20 70 6f 70 75 6c 61 72 | 20 44 4b 42 20 72 61 79 | popular| DKB ray|
|000004c0| 74 72 61 63 65 72 20 76 | 65 72 73 69 6f 6e 20 32 |tracer v|ersion 2|
|000004d0| 2e 31 32 2e 0d 2a 20 44 | 4b 42 54 72 61 63 65 20 |.12..* D|KBTrace |
|000004e0| 77 61 73 20 6f 72 69 67 | 69 6e 61 6c 6c 79 20 77 |was orig|inally w|
|000004f0| 72 69 74 74 65 6e 20 62 | 79 20 44 61 76 69 64 20 |ritten b|y David |
|00000500| 4b 2e 20 42 75 63 6b 2e | 0d 2a 20 44 4b 42 54 72 |K. Buck.|.* DKBTr|
|00000510| 61 63 65 20 56 65 72 20 | 32 2e 30 2d 32 2e 31 32 |ace Ver |2.0-2.12|
|00000520| 20 77 65 72 65 20 77 72 | 69 74 74 65 6e 20 62 79 | were wr|itten by|
|00000530| 20 44 61 76 69 64 20 4b | 2e 20 42 75 63 6b 20 26 | David K|. Buck &|
|00000540| 20 41 61 72 6f 6e 20 41 | 2e 20 43 6f 6c 6c 69 6e | Aaron A|. Collin|
|00000550| 73 2e 0d 2a 0d 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |s..*.***|********|
|00000560| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000570| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000580| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000590| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000005a0| 2a 2a 2f 0d 0d 23 69 6e | 63 6c 75 64 65 20 22 66 |**/..#in|clude "f|
|000005b0| 72 61 6d 65 2e 68 22 0d | 23 69 6e 63 6c 75 64 65 |rame.h".|#include|
|000005c0| 20 22 76 65 63 74 6f 72 | 2e 68 22 0d 23 69 6e 63 | "vector|.h".#inc|
|000005d0| 6c 75 64 65 20 22 70 6f | 76 70 72 6f 74 6f 2e 68 |lude "po|vproto.h|
|000005e0| 22 0d 0d 23 69 66 6e 64 | 65 66 20 6d 69 6e 0d 23 |"..#ifnd|ef min.#|
|000005f0| 64 65 66 69 6e 65 20 6d | 69 6e 28 78 2c 79 29 20 |define m|in(x,y) |
|00000600| 28 28 78 29 3c 28 79 29 | 3f 28 78 29 3a 28 79 29 |((x)<(y)|?(x):(y)|
|00000610| 29 0d 23 65 6e 64 69 66 | 0d 23 69 66 6e 64 65 66 |).#endif|.#ifndef|
|00000620| 20 6d 61 78 0d 23 64 65 | 66 69 6e 65 20 6d 61 78 | max.#de|fine max|
|00000630| 28 78 2c 79 29 20 28 28 | 78 29 3e 28 79 29 3f 28 |(x,y) ((|x)>(y)?(|
|00000640| 78 29 3a 28 79 29 29 0d | 23 65 6e 64 69 66 0d 0d |x):(y)).|#endif..|
|00000650| 4d 45 54 48 4f 44 53 20 | 42 6c 6f 62 5f 4d 65 74 |METHODS |Blob_Met|
|00000660| 68 6f 64 73 20 3d 0d 20 | 20 7b 20 0d 20 20 41 6c |hods =. | { . Al|
|00000670| 6c 5f 42 6c 6f 62 5f 49 | 6e 74 65 72 73 65 63 74 |l_Blob_I|ntersect|
|00000680| 69 6f 6e 73 2c 0d 20 20 | 49 6e 73 69 64 65 5f 42 |ions,. |Inside_B|
|00000690| 6c 6f 62 2c 20 42 6c 6f | 62 5f 4e 6f 72 6d 61 6c |lob, Blo|b_Normal|
|000006a0| 2c 0d 20 20 43 6f 70 79 | 5f 42 6c 6f 62 2c 0d 20 |,. Copy|_Blob,. |
|000006b0| 20 54 72 61 6e 73 6c 61 | 74 65 5f 42 6c 6f 62 2c | Transla|te_Blob,|
|000006c0| 20 52 6f 74 61 74 65 5f | 42 6c 6f 62 2c 20 53 63 | Rotate_|Blob, Sc|
|000006d0| 61 6c 65 5f 42 6c 6f 62 | 2c 20 54 72 61 6e 73 66 |ale_Blob|, Transf|
|000006e0| 6f 72 6d 5f 42 6c 6f 62 | 2c 0d 20 20 49 6e 76 65 |orm_Blob|,. Inve|
|000006f0| 72 74 5f 42 6c 6f 62 2c | 20 44 65 73 74 72 6f 79 |rt_Blob,| Destroy|
|00000700| 5f 42 6c 6f 62 0d 7d 3b | 0d 0d 65 78 74 65 72 6e |_Blob.};|..extern|
|00000710| 20 6c 6f 6e 67 20 52 61 | 79 5f 42 6c 6f 62 5f 54 | long Ra|y_Blob_T|
|00000720| 65 73 74 73 2c 20 52 61 | 79 5f 42 6c 6f 62 5f 54 |ests, Ra|y_Blob_T|
|00000730| 65 73 74 73 5f 53 75 63 | 63 65 65 64 65 64 3b 0d |ests_Suc|ceeded;.|
|00000740| 65 78 74 65 72 6e 20 69 | 6e 74 20 53 68 61 64 6f |extern i|nt Shado|
|00000750| 77 5f 54 65 73 74 5f 46 | 6c 61 67 3b 0d 0d 73 74 |w_Test_F|lag;..st|
|00000760| 61 74 69 63 20 69 6e 74 | 20 64 65 74 65 72 6d 69 |atic int| determi|
|00000770| 6e 65 5f 69 6e 66 6c 75 | 65 6e 63 65 73 20 50 41 |ne_influ|ences PA|
|00000780| 52 41 4d 53 28 28 56 45 | 43 54 4f 52 20 2a 50 2c |RAMS((VE|CTOR *P,|
|00000790| 20 56 45 43 54 4f 52 20 | 2a 44 2c 20 42 4c 4f 42 | VECTOR |*D, BLOB|
|000007a0| 20 2a 62 6c 6f 62 2c 20 | 44 42 4c 20 6d 69 6e 64 | *blob, |DBL mind|
|000007b0| 69 73 74 29 29 3b 0d 73 | 74 61 74 69 63 20 44 42 |ist));.s|tatic DB|
|000007c0| 4c 20 63 61 6c 63 75 6c | 61 74 65 5f 66 69 65 6c |L calcul|ate_fiel|
|000007d0| 64 5f 76 61 6c 75 65 20 | 50 41 52 41 4d 53 20 28 |d_value |PARAMS (|
|000007e0| 28 4f 42 4a 45 43 54 20 | 2a 6f 62 6a 2c 20 56 45 |(OBJECT |*obj, VE|
|000007f0| 43 54 4f 52 20 2a 50 6f | 73 29 29 3b 0d 0d 23 69 |CTOR *Po|s));..#i|
|00000800| 66 6e 64 65 66 20 42 6c | 6f 62 5f 54 6f 6c 65 72 |fndef Bl|ob_Toler|
|00000810| 61 6e 63 65 20 0d 23 64 | 65 66 69 6e 65 20 42 6c |ance .#d|efine Bl|
|00000820| 6f 62 5f 54 6f 6c 65 72 | 61 6e 63 65 20 31 2e 30 |ob_Toler|ance 1.0|
|00000830| 65 2d 33 0d 23 65 6e 64 | 69 66 0d 0d 23 64 65 66 |e-3.#end|if..#def|
|00000840| 69 6e 65 20 43 4f 45 46 | 46 5f 4c 49 4d 49 54 20 |ine COEF|F_LIMIT |
|00000850| 31 2e 30 65 2d 32 30 0d | 23 64 65 66 69 6e 65 20 |1.0e-20.|#define |
|00000860| 49 4e 53 49 44 45 5f 54 | 4f 4c 45 52 41 4e 43 45 |INSIDE_T|OLERANCE|
|00000870| 20 31 2e 30 65 2d 36 0d | 0d 2f 2a 20 53 74 61 72 | 1.0e-6.|./* Star|
|00000880| 74 69 6e 67 20 77 69 74 | 68 20 74 68 65 20 64 65 |ting wit|h the de|
|00000890| 6e 73 69 74 79 20 66 75 | 6e 63 74 69 6f 6e 3a 20 |nsity fu|nction: |
|000008a0| 28 31 2d 72 5e 32 29 5e | 32 2c 20 77 65 20 68 61 |(1-r^2)^|2, we ha|
|000008b0| 76 65 20 61 20 66 69 65 | 6c 64 0d 20 20 20 74 68 |ve a fie|ld. th|
|000008c0| 61 74 20 76 61 72 69 65 | 73 20 69 6e 20 73 74 72 |at varie|s in str|
|000008d0| 65 6e 67 74 68 20 66 72 | 6f 6d 20 31 20 61 74 20 |ength fr|om 1 at |
|000008e0| 72 20 3d 20 30 20 74 6f | 20 30 20 61 74 20 72 20 |r = 0 to| 0 at r |
|000008f0| 3d 20 31 2e 20 20 42 79 | 0d 20 20 20 73 75 62 73 |= 1. By|. subs|
|00000900| 74 69 74 75 74 69 6e 67 | 20 72 2f 72 61 64 20 66 |tituting| r/rad f|
|00000910| 6f 72 20 72 2c 20 77 65 | 20 63 61 6e 20 61 64 6a |or r, we| can adj|
|00000920| 75 73 74 20 74 68 65 20 | 72 61 6e 67 65 20 6f 66 |ust the |range of|
|00000930| 20 69 6e 66 6c 75 65 6e | 63 65 0d 20 20 20 6f 66 | influen|ce. of|
|00000940| 20 61 20 70 61 72 74 69 | 63 75 6c 61 72 20 63 6f | a parti|cular co|
|00000950| 6d 70 6f 6e 65 6e 74 2e | 20 20 42 79 20 6d 75 6c |mponent.| By mul|
|00000960| 74 69 70 6c 69 63 61 74 | 69 6f 6e 20 62 79 20 63 |tiplicat|ion by c|
|00000970| 6f 65 66 66 2c 20 77 65 | 20 63 61 6e 0d 20 20 20 |oeff, we| can. |
|00000980| 61 64 6a 75 73 74 20 74 | 68 65 20 61 6d 6f 75 6e |adjust t|he amoun|
|00000990| 74 20 6f 66 20 74 6f 74 | 61 6c 20 63 6f 6e 74 72 |t of tot|al contr|
|000009a0| 69 62 75 74 69 6f 6e 2c | 20 67 69 76 69 6e 67 20 |ibution,| giving |
|000009b0| 74 68 65 20 66 6f 72 6d | 75 6c 61 3a 0d 20 20 20 |the form|ula:. |
|000009c0| 20 20 20 63 6f 65 66 66 | 20 2a 20 28 31 20 2d 20 | coeff| * (1 - |
|000009d0| 28 72 2f 72 61 64 29 5e | 32 29 5e 32 0d 20 20 20 |(r/rad)^|2)^2. |
|000009e0| 54 68 69 73 20 76 61 72 | 69 65 73 20 69 6e 20 73 |This var|ies in s|
|000009f0| 74 72 65 6e 67 74 68 20 | 66 72 6f 6d 20 63 6f 65 |trength |from coe|
|00000a00| 66 66 20 61 74 20 72 20 | 3d 20 30 2c 20 74 6f 20 |ff at r |= 0, to |
|00000a10| 30 20 61 74 20 72 20 3d | 20 72 61 64 2e 20 2a 2f |0 at r =| rad. */|
|00000a20| 0d 76 6f 69 64 0d 4d 61 | 6b 65 42 6c 6f 62 28 62 |.void.Ma|keBlob(b|
|00000a30| 6c 6f 62 2c 20 74 68 72 | 65 73 68 6f 6c 64 2c 20 |lob, thr|eshold, |
|00000a40| 62 6c 6f 62 6c 69 73 74 | 2c 20 6e 70 6f 69 6e 74 |bloblist|, npoint|
|00000a50| 73 2c 20 73 66 6c 61 67 | 29 0d 42 4c 4f 42 20 2a |s, sflag|).BLOB *|
|00000a60| 62 6c 6f 62 3b 0d 44 42 | 4c 20 74 68 72 65 73 68 |blob;.DB|L thresh|
|00000a70| 6f 6c 64 3b 0d 62 6c 6f | 62 73 74 61 63 6b 70 74 |old;.blo|bstackpt|
|00000a80| 72 20 62 6c 6f 62 6c 69 | 73 74 3b 0d 69 6e 74 20 |r blobli|st;.int |
|00000a90| 6e 70 6f 69 6e 74 73 3b | 0d 69 6e 74 20 73 66 6c |npoints;|.int sfl|
|00000aa0| 61 67 3b 0d 20 20 7b 0d | 20 20 75 6e 73 69 67 6e |ag;. {.| unsign|
|00000ab0| 65 64 20 69 3b 0d 20 20 | 44 42 4c 20 72 61 64 2c |ed i;. |DBL rad,|
|00000ac0| 20 63 6f 65 66 66 3b 0d | 20 20 62 6c 6f 62 73 74 | coeff;.| blobst|
|00000ad0| 61 63 6b 70 74 72 20 74 | 65 6d 70 3b 0d 20 20 56 |ackptr t|emp;. V|
|00000ae0| 45 43 54 4f 52 20 6d 69 | 6e 73 2c 20 6d 61 78 73 |ECTOR mi|ns, maxs|
|00000af0| 3b 0d 0d 20 20 69 66 20 | 28 6e 70 6f 69 6e 74 73 |;.. if |(npoints|
|00000b00| 20 3c 20 31 29 20 0d 20 | 20 20 20 45 72 72 6f 72 | < 1) . | Error|
|00000b10| 28 22 4e 65 65 64 20 61 | 74 20 6c 65 61 73 74 20 |("Need a|t least |
|00000b20| 6f 6e 65 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 69 6e |one comp|onent in|
|00000b30| 20 61 20 62 6c 6f 62 2e | 22 29 3b 0d 0d 20 20 62 | a blob.|");.. b|
|00000b40| 6c 6f 62 2d 3e 74 68 72 | 65 73 68 6f 6c 64 20 3d |lob->thr|eshold =|
|00000b50| 20 74 68 72 65 73 68 6f | 6c 64 3b 0d 20 20 62 6c | thresho|ld;. bl|
|00000b60| 6f 62 2d 3e 6c 69 73 74 | 20 3d 20 28 42 6c 6f 62 |ob->list| = (Blob|
|00000b70| 5f 45 6c 65 6d 65 6e 74 | 20 2a 2a 29 6d 61 6c 6c |_Element| **)mall|
|00000b80| 6f 63 28 6e 70 6f 69 6e | 74 73 2a 73 69 7a 65 6f |oc(npoin|ts*sizeo|
|00000b90| 66 28 42 6c 6f 62 5f 45 | 6c 65 6d 65 6e 74 20 2a |f(Blob_E|lement *|
|00000ba0| 29 29 3b 0d 20 20 69 66 | 20 28 62 6c 6f 62 2d 3e |));. if| (blob->|
|00000bb0| 6c 69 73 74 20 3d 3d 20 | 4e 55 4c 4c 29 20 0d 20 |list == |NULL) . |
|00000bc0| 20 20 20 4d 41 45 72 72 | 6f 72 28 22 62 6c 6f 62 | MAErr|or("blob|
|00000bd0| 20 64 61 74 61 22 29 3b | 0d 20 20 66 6f 72 20 28 | data");|. for (|
|00000be0| 69 3d 30 3b 69 20 3c 20 | 28 75 6e 73 69 67 6e 65 |i=0;i < |(unsigne|
|00000bf0| 64 29 6e 70 6f 69 6e 74 | 73 3b 69 2b 2b 29 20 0d |d)npoint|s;i++) .|
|00000c00| 20 20 20 20 7b 0d 20 20 | 20 20 62 6c 6f 62 2d 3e | {. | blob->|
|00000c10| 6c 69 73 74 5b 69 5d 20 | 3d 20 28 42 6c 6f 62 5f |list[i] |= (Blob_|
|00000c20| 45 6c 65 6d 65 6e 74 20 | 2a 29 6d 61 6c 6c 6f 63 |Element |*)malloc|
|00000c30| 28 73 69 7a 65 6f 66 28 | 42 6c 6f 62 5f 45 6c 65 |(sizeof(|Blob_Ele|
|00000c40| 6d 65 6e 74 29 29 3b 0d | 20 20 20 20 69 66 20 28 |ment));.| if (|
|00000c50| 62 6c 6f 62 2d 3e 6c 69 | 73 74 5b 69 5d 20 3d 3d |blob->li|st[i] ==|
|00000c60| 20 4e 55 4c 4c 29 0d 20 | 20 20 20 20 20 4d 41 45 | NULL). | MAE|
|00000c70| 72 72 6f 72 28 22 62 6c | 6f 62 20 64 61 74 61 22 |rror("bl|ob data"|
|00000c80| 29 3b 0d 20 20 20 20 7d | 0d 0d 20 20 62 6c 6f 62 |);. }|.. blob|
|00000c90| 2d 3e 63 6f 75 6e 74 20 | 3d 20 6e 70 6f 69 6e 74 |->count |= npoint|
|00000ca0| 73 3b 0d 20 20 62 6c 6f | 62 2d 3e 53 74 75 72 6d |s;. blo|b->Sturm|
|00000cb0| 5f 46 6c 61 67 20 3d 20 | 73 66 6c 61 67 3b 0d 0d |_Flag = |sflag;..|
|00000cc0| 20 20 2f 2a 20 49 6e 69 | 74 69 61 6c 69 7a 65 20 | /* Ini|tialize |
|00000cd0| 74 68 65 20 62 6c 6f 62 | 20 64 61 74 61 20 2a 2f |the blob| data */|
|00000ce0| 0d 20 20 66 6f 72 28 69 | 3d 30 3b 69 20 3c 20 28 |. for(i|=0;i < (|
|00000cf0| 75 6e 73 69 67 6e 65 64 | 29 6e 70 6f 69 6e 74 73 |unsigned|)npoints|
|00000d00| 3b 69 2b 2b 29 20 0d 20 | 20 20 20 7b 0d 20 20 20 |;i++) . | {. |
|00000d10| 20 74 65 6d 70 20 3d 20 | 62 6c 6f 62 6c 69 73 74 | temp = |bloblist|
|00000d20| 3b 0d 20 20 20 20 69 66 | 20 28 66 61 62 73 28 74 |;. if| (fabs(t|
|00000d30| 65 6d 70 2d 3e 65 6c 65 | 6d 2e 63 6f 65 66 66 73 |emp->ele|m.coeffs|
|00000d40| 5b 32 5d 29 20 3c 20 45 | 50 53 49 4c 4f 4e 20 7c |[2]) < E|PSILON ||
|00000d50| 7c 0d 20 20 20 20 20 20 | 74 65 6d 70 2d 3e 65 6c ||. |temp->el|
|00000d60| 65 6d 2e 72 61 64 69 75 | 73 32 20 3c 20 45 50 53 |em.radiu|s2 < EPS|
|00000d70| 49 4c 4f 4e 29 20 0d 20 | 20 20 20 20 20 7b 0d 20 |ILON) . | {. |
|00000d80| 20 20 20 20 20 70 65 72 | 72 6f 72 28 22 44 65 67 | per|ror("Deg|
|00000d90| 65 6e 65 72 61 74 65 20 | 62 6c 6f 62 20 65 6c 65 |enerate |blob ele|
|00000da0| 6d 65 6e 74 5c 6e 22 29 | 3b 0d 20 20 20 20 20 20 |ment\n")|;. |
|00000db0| 7d 0d 20 20 20 20 2f 2a | 20 53 74 6f 72 65 20 62 |}. /*| Store b|
|00000dc0| 6c 6f 62 20 73 70 65 63 | 69 66 69 63 20 69 6e 66 |lob spec|ific inf|
|00000dd0| 6f 72 6d 61 74 69 6f 6e | 20 2a 2f 0d 20 20 20 20 |ormation| */. |
|00000de0| 72 61 64 20 3d 20 74 65 | 6d 70 2d 3e 65 6c 65 6d |rad = te|mp->elem|
|00000df0| 2e 72 61 64 69 75 73 32 | 3b 0d 20 20 20 20 72 61 |.radius2|;. ra|
|00000e00| 64 20 2a 3d 20 72 61 64 | 3b 0d 20 20 20 20 63 6f |d *= rad|;. co|
|00000e10| 65 66 66 20 3d 20 74 65 | 6d 70 2d 3e 65 6c 65 6d |eff = te|mp->elem|
|00000e20| 2e 63 6f 65 66 66 73 5b | 32 5d 3b 0d 20 20 20 20 |.coeffs[|2];. |
|00000e30| 62 6c 6f 62 2d 3e 6c 69 | 73 74 5b 69 5d 2d 3e 72 |blob->li|st[i]->r|
|00000e40| 61 64 69 75 73 32 20 20 | 20 3d 20 72 61 64 3b 0d |adius2 | = rad;.|
|00000e50| 20 20 20 20 62 6c 6f 62 | 2d 3e 6c 69 73 74 5b 69 | blob|->list[i|
|00000e60| 5d 2d 3e 63 6f 65 66 66 | 73 5b 32 5d 20 3d 20 63 |]->coeff|s[2] = c|
|00000e70| 6f 65 66 66 3b 0d 20 20 | 20 20 62 6c 6f 62 2d 3e |oeff;. | blob->|
|00000e80| 6c 69 73 74 5b 69 5d 2d | 3e 63 6f 65 66 66 73 5b |list[i]-|>coeffs[|
|00000e90| 31 5d 20 3d 20 2d 28 32 | 2e 30 20 2a 20 63 6f 65 |1] = -(2|.0 * coe|
|00000ea0| 66 66 29 20 2f 20 72 61 | 64 3b 0d 20 20 20 20 62 |ff) / ra|d;. b|
|00000eb0| 6c 6f 62 2d 3e 6c 69 73 | 74 5b 69 5d 2d 3e 63 6f |lob->lis|t[i]->co|
|00000ec0| 65 66 66 73 5b 30 5d 20 | 3d 20 63 6f 65 66 66 20 |effs[0] |= coeff |
|00000ed0| 2f 20 28 72 61 64 20 2a | 20 72 61 64 29 3b 0d 20 |/ (rad *| rad);. |
|00000ee0| 20 20 20 62 6c 6f 62 2d | 3e 6c 69 73 74 5b 69 5d | blob-|>list[i]|
|00000ef0| 2d 3e 70 6f 73 2e 78 20 | 3d 20 74 65 6d 70 2d 3e |->pos.x |= temp->|
|00000f00| 65 6c 65 6d 2e 70 6f 73 | 2e 78 3b 0d 20 20 20 20 |elem.pos|.x;. |
|00000f10| 62 6c 6f 62 2d 3e 6c 69 | 73 74 5b 69 5d 2d 3e 70 |blob->li|st[i]->p|
|00000f20| 6f 73 2e 79 20 3d 20 74 | 65 6d 70 2d 3e 65 6c 65 |os.y = t|emp->ele|
|00000f30| 6d 2e 70 6f 73 2e 79 3b | 0d 20 20 20 20 62 6c 6f |m.pos.y;|. blo|
|00000f40| 62 2d 3e 6c 69 73 74 5b | 69 5d 2d 3e 70 6f 73 2e |b->list[|i]->pos.|
|00000f50| 7a 20 3d 20 74 65 6d 70 | 2d 3e 65 6c 65 6d 2e 70 |z = temp|->elem.p|
|00000f60| 6f 73 2e 7a 3b 0d 0d 20 | 20 20 20 72 61 64 20 3d |os.z;.. | rad =|
|00000f70| 20 74 65 6d 70 2d 3e 65 | 6c 65 6d 2e 72 61 64 69 | temp->e|lem.radi|
|00000f80| 75 73 32 3b 0d 20 20 20 | 20 69 66 20 28 69 20 3d |us2;. | if (i =|
|00000f90| 3d 20 30 29 20 0d 20 20 | 20 20 20 20 7b 0d 20 20 |= 0) . | {. |
|00000fa0| 20 20 20 20 2f 2a 20 46 | 69 72 73 74 20 63 6f 6d | /* F|irst com|
|00000fb0| 70 6f 6e 65 6e 74 2c 20 | 6a 75 73 74 20 73 65 74 |ponent, |just set|
|00000fc0| 20 74 68 65 20 62 6f 75 | 6e 64 73 20 2a 2f 0d 20 | the bou|nds */. |
|00000fd0| 20 20 20 20 20 4d 61 6b | 65 5f 56 65 63 74 6f 72 | Mak|e_Vector|
|00000fe0| 28 26 6d 69 6e 73 2c 0d | 20 20 20 20 20 20 20 20 |(&mins,.| |
|00000ff0| 74 65 6d 70 2d 3e 65 6c | 65 6d 2e 70 6f 73 2e 78 |temp->el|em.pos.x|
|00001000| 2d 72 61 64 2c 0d 20 20 | 20 20 20 20 20 20 74 65 |-rad,. | te|
|00001010| 6d 70 2d 3e 65 6c 65 6d | 2e 70 6f 73 2e 79 2d 72 |mp->elem|.pos.y-r|
|00001020| 61 64 2c 0d 20 20 20 20 | 20 20 20 20 74 65 6d 70 |ad,. | temp|
|00001030| 2d 3e 65 6c 65 6d 2e 70 | 6f 73 2e 7a 2d 72 61 64 |->elem.p|os.z-rad|
|00001040| 29 0d 20 20 20 20 20 20 | 20 20 4d 61 6b 65 5f 56 |). | Make_V|
|00001050| 65 63 74 6f 72 28 26 6d | 61 78 73 2c 0d 20 20 20 |ector(&m|axs,. |
|00001060| 20 20 20 20 20 20 20 74 | 65 6d 70 2d 3e 65 6c 65 | t|emp->ele|
|00001070| 6d 2e 70 6f 73 2e 78 2b | 72 61 64 2c 0d 20 20 20 |m.pos.x+|rad,. |
|00001080| 20 20 20 20 20 20 20 74 | 65 6d 70 2d 3e 65 6c 65 | t|emp->ele|
|00001090| 6d 2e 70 6f 73 2e 79 2b | 72 61 64 2c 0d 20 20 20 |m.pos.y+|rad,. |
|000010a0| 20 20 20 20 20 20 20 74 | 65 6d 70 2d 3e 65 6c 65 | t|emp->ele|
|000010b0| 6d 2e 70 6f 73 2e 7a 2b | 72 61 64 29 0d 20 20 20 |m.pos.z+|rad). |
|000010c0| 20 20 20 20 20 20 20 7d | 0d 20 20 20 20 65 6c 73 | }|. els|
|000010d0| 65 20 0d 20 20 20 20 20 | 20 7b 0d 20 20 20 20 20 |e . | {. |
|000010e0| 20 2f 2a 20 43 68 65 63 | 6b 20 6d 69 6e 2f 6d 61 | /* Chec|k min/ma|
|000010f0| 78 20 6f 6e 20 74 68 65 | 20 62 6f 75 6e 64 73 20 |x on the| bounds |
|00001100| 2a 2f 0d 20 20 20 20 20 | 20 20 20 6d 69 6e 73 2e |*/. | mins.|
|00001110| 78 20 3d 20 6d 69 6e 28 | 6d 69 6e 73 2e 78 2c 20 |x = min(|mins.x, |
|00001120| 74 65 6d 70 2d 3e 65 6c | 65 6d 2e 70 6f 73 2e 78 |temp->el|em.pos.x|
|00001130| 20 2d 20 72 61 64 29 3b | 0d 20 20 20 20 20 20 6d | - rad);|. m|
|00001140| 69 6e 73 2e 79 20 3d 20 | 6d 69 6e 28 6d 69 6e 73 |ins.y = |min(mins|
|00001150| 2e 79 2c 20 74 65 6d 70 | 2d 3e 65 6c 65 6d 2e 70 |.y, temp|->elem.p|
|00001160| 6f 73 2e 79 20 2d 20 72 | 61 64 29 3b 0d 20 20 20 |os.y - r|ad);. |
|00001170| 20 20 20 6d 69 6e 73 2e | 7a 20 3d 20 6d 69 6e 28 | mins.|z = min(|
|00001180| 6d 69 6e 73 2e 7a 2c 20 | 74 65 6d 70 2d 3e 65 6c |mins.z, |temp->el|
|00001190| 65 6d 2e 70 6f 73 2e 7a | 20 2d 20 72 61 64 29 3b |em.pos.z| - rad);|
|000011a0| 0d 20 20 20 20 20 20 6d | 61 78 73 2e 78 20 3d 20 |. m|axs.x = |
|000011b0| 6d 61 78 28 6d 61 78 73 | 2e 78 2c 20 74 65 6d 70 |max(maxs|.x, temp|
|000011c0| 2d 3e 65 6c 65 6d 2e 70 | 6f 73 2e 78 20 2b 20 72 |->elem.p|os.x + r|
|000011d0| 61 64 29 3b 0d 20 20 20 | 20 20 20 6d 61 78 73 2e |ad);. | maxs.|
|000011e0| 79 20 3d 20 6d 61 78 28 | 6d 61 78 73 2e 79 2c 20 |y = max(|maxs.y, |
|000011f0| 74 65 6d 70 2d 3e 65 6c | 65 6d 2e 70 6f 73 2e 79 |temp->el|em.pos.y|
|00001200| 20 2b 20 72 61 64 29 3b | 0d 20 20 20 20 20 20 6d | + rad);|. m|
|00001210| 61 78 73 2e 7a 20 3d 20 | 6d 61 78 28 6d 61 78 73 |axs.z = |max(maxs|
|00001220| 2e 7a 2c 20 74 65 6d 70 | 2d 3e 65 6c 65 6d 2e 70 |.z, temp|->elem.p|
|00001230| 6f 73 2e 7a 20 2b 20 72 | 61 64 29 3b 0d 20 20 20 |os.z + r|ad);. |
|00001240| 20 20 20 7d 0d 0d 20 20 | 20 20 62 6c 6f 62 6c 69 | }.. | blobli|
|00001250| 73 74 20 3d 20 62 6c 6f | 62 6c 69 73 74 2d 3e 6e |st = blo|blist->n|
|00001260| 65 78 74 3b 0d 20 20 20 | 20 66 72 65 65 28 74 65 |ext;. | free(te|
|00001270| 6d 70 29 3b 0d 20 20 20 | 20 7d 0d 0d 20 20 62 6c |mp);. | }.. bl|
|00001280| 6f 62 2d 3e 42 6f 75 6e | 64 73 2e 4c 6f 77 65 72 |ob->Boun|ds.Lower|
|00001290| 5f 4c 65 66 74 20 3d 20 | 6d 69 6e 73 3b 0d 20 20 |_Left = |mins;. |
|000012a0| 56 53 75 62 28 62 6c 6f | 62 2d 3e 42 6f 75 6e 64 |VSub(blo|b->Bound|
|000012b0| 73 2e 4c 65 6e 67 74 68 | 73 2c 20 6d 61 78 73 2c |s.Length|s, maxs,|
|000012c0| 20 6d 69 6e 73 29 3b 0d | 0d 20 20 2f 2a 20 20 41 | mins);.|. /* A|
|000012d0| 6c 6c 6f 63 61 74 65 20 | 6d 65 6d 6f 72 79 20 66 |llocate |memory f|
|000012e0| 6f 72 20 69 6e 74 65 72 | 73 65 63 74 69 6f 6e 20 |or inter|section |
|000012f0| 69 6e 74 65 72 76 61 6c | 73 20 2a 2f 0d 20 20 6e |interval|s */. n|
|00001300| 70 6f 69 6e 74 73 20 2a | 3d 20 32 3b 0d 20 20 62 |points *|= 2;. b|
|00001310| 6c 6f 62 2d 3e 69 6e 74 | 65 72 76 61 6c 73 20 3d |lob->int|ervals =|
|00001320| 20 28 42 6c 6f 62 5f 49 | 6e 74 65 72 76 61 6c 20 | (Blob_I|nterval |
|00001330| 2a 29 6d 61 6c 6c 6f 63 | 28 6e 70 6f 69 6e 74 73 |*)malloc|(npoints|
|00001340| 2a 73 69 7a 65 6f 66 28 | 42 6c 6f 62 5f 49 6e 74 |*sizeof(|Blob_Int|
|00001350| 65 72 76 61 6c 29 29 3b | 0d 20 20 69 66 20 28 62 |erval));|. if (b|
|00001360| 6c 6f 62 2d 3e 69 6e 74 | 65 72 76 61 6c 73 20 3d |lob->int|ervals =|
|00001370| 3d 20 4e 55 4c 4c 29 20 | 0d 20 20 20 20 4d 41 45 |= NULL) |. MAE|
|00001380| 72 72 6f 72 28 22 62 6c | 6f 62 20 64 61 74 61 22 |rror("bl|ob data"|
|00001390| 29 3b 0d 20 20 7d 0d 0d | 2f 2a 20 4d 61 6b 65 20 |);. }..|/* Make |
|000013a0| 61 20 73 6f 72 74 65 64 | 20 6c 69 73 74 20 6f 66 |a sorted| list of|
|000013b0| 20 70 6f 69 6e 74 73 20 | 61 6c 6f 6e 67 20 74 68 | points |along th|
|000013c0| 65 20 72 61 79 20 74 68 | 61 74 20 74 68 65 20 76 |e ray th|at the v|
|000013d0| 61 72 69 6f 75 73 20 62 | 6c 6f 62 0d 20 20 20 63 |arious b|lob. c|
|000013e0| 6f 6d 70 6f 6e 65 6e 74 | 73 20 73 74 61 72 74 20 |omponent|s start |
|000013f0| 61 6e 64 20 73 74 6f 70 | 20 61 64 64 69 6e 67 20 |and stop| adding |
|00001400| 74 68 65 69 72 20 69 6e | 66 6c 75 65 6e 63 65 2e |their in|fluence.|
|00001410| 20 20 49 74 20 77 6f 75 | 6c 64 20 74 61 6b 65 0d | It wou|ld take.|
|00001420| 20 20 20 61 20 76 65 72 | 79 20 63 6f 6d 70 6c 65 | a ver|y comple|
|00001430| 78 20 62 6c 6f 62 20 28 | 77 69 74 68 20 6d 61 6e |x blob (|with man|
|00001440| 79 20 63 6f 6d 70 6f 6e | 65 6e 74 73 20 61 6c 6f |y compon|ents alo|
|00001450| 6e 67 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 72 |ng the c|urrent r|
|00001460| 61 79 29 0d 20 20 20 74 | 6f 20 77 61 72 72 61 6e |ay). t|o warran|
|00001470| 74 20 74 68 65 20 6f 76 | 65 72 68 65 61 64 20 6f |t the ov|erhead o|
|00001480| 66 20 75 73 69 6e 67 20 | 61 20 66 61 73 74 65 72 |f using |a faster|
|00001490| 20 73 6f 72 74 20 74 65 | 63 68 6e 69 71 75 65 2e | sort te|chnique.|
|000014a0| 20 2a 2f 0d 73 74 61 74 | 69 63 20 69 6e 74 0d 64 | */.stat|ic int.d|
|000014b0| 65 74 65 72 6d 69 6e 65 | 5f 69 6e 66 6c 75 65 6e |etermine|_influen|
|000014c0| 63 65 73 28 50 2c 20 44 | 2c 20 62 6c 6f 62 2c 20 |ces(P, D|, blob, |
|000014d0| 6d 69 6e 64 69 73 74 29 | 0d 56 45 43 54 4f 52 20 |mindist)|.VECTOR |
|000014e0| 2a 50 2c 20 2a 44 3b 0d | 42 4c 4f 42 20 2a 62 6c |*P, *D;.|BLOB *bl|
|000014f0| 6f 62 3b 0d 44 42 4c 20 | 6d 69 6e 64 69 73 74 3b |ob;.DBL |mindist;|
|00001500| 0d 20 20 7b 0d 20 20 69 | 6e 74 20 69 2c 20 6a 2c |. {. i|nt i, j,|
|00001510| 20 6b 2c 20 63 6e 74 3b | 0d 20 20 44 42 4c 20 62 | k, cnt;|. DBL b|
|00001520| 2c 20 74 2c 20 74 30 2c | 20 74 31 2c 20 64 69 73 |, t, t0,| t1, dis|
|00001530| 63 3b 0d 20 20 56 45 43 | 54 4f 52 20 56 3b 0d 20 |c;. VEC|TOR V;. |
|00001540| 20 42 6c 6f 62 5f 49 6e | 74 65 72 76 61 6c 20 2a | Blob_In|terval *|
|00001550| 69 6e 74 65 72 76 61 6c | 73 20 3d 20 62 6c 6f 62 |interval|s = blob|
|00001560| 2d 3e 69 6e 74 65 72 76 | 61 6c 73 3b 0d 0d 20 20 |->interv|als;.. |
|00001570| 63 6e 74 20 3d 20 30 3b | 0d 20 20 66 6f 72 20 28 |cnt = 0;|. for (|
|00001580| 69 3d 30 3b 69 3c 62 6c | 6f 62 2d 3e 63 6f 75 6e |i=0;i<bl|ob->coun|
|00001590| 74 3b 69 2b 2b 29 20 0d | 20 20 20 20 7b 0d 20 20 |t;i++) .| {. |
|000015a0| 20 20 2f 2a 20 55 73 65 | 20 73 74 61 6e 64 61 72 | /* Use| standar|
|000015b0| 64 20 73 70 68 65 72 65 | 20 69 6e 74 65 72 73 65 |d sphere| interse|
|000015c0| 63 74 69 6f 6e 20 72 6f | 75 74 69 6e 65 0d 20 20 |ction ro|utine. |
|000015d0| 20 20 20 20 20 20 20 74 | 6f 20 64 65 74 65 72 6d | t|o determ|
|000015e0| 69 6e 65 20 77 68 65 72 | 65 20 74 68 65 20 72 61 |ine wher|e the ra|
|000015f0| 79 20 68 69 74 73 20 74 | 68 65 20 76 6f 6c 75 6d |y hits t|he volum|
|00001600| 65 0d 20 20 20 20 20 20 | 20 20 20 6f 66 20 69 6e |e. | of in|
|00001610| 66 6c 75 65 6e 63 65 20 | 6f 66 20 65 61 63 68 20 |fluence |of each |
|00001620| 63 6f 6d 70 6f 6e 65 6e | 74 20 6f 66 20 74 68 65 |componen|t of the|
|00001630| 20 62 6c 6f 62 2e 20 2a | 2f 0d 20 20 20 20 56 53 | blob. *|/. VS|
|00001640| 75 62 28 56 2c 20 62 6c | 6f 62 2d 3e 6c 69 73 74 |ub(V, bl|ob->list|
|00001650| 5b 69 5d 2d 3e 70 6f 73 | 2c 20 2a 50 29 3b 0d 20 |[i]->pos|, *P);. |
|00001660| 20 20 20 56 44 6f 74 28 | 62 2c 20 56 2c 20 2a 44 | VDot(|b, V, *D|
|00001670| 29 3b 0d 20 20 20 20 56 | 44 6f 74 28 74 2c 20 56 |);. V|Dot(t, V|
|00001680| 2c 20 56 29 3b 0d 20 20 | 20 20 64 69 73 63 20 3d |, V);. | disc =|
|00001690| 20 62 20 2a 20 62 20 2d | 20 74 20 2b 20 62 6c 6f | b * b -| t + blo|
|000016a0| 62 2d 3e 6c 69 73 74 5b | 69 5d 2d 3e 72 61 64 69 |b->list[|i]->radi|
|000016b0| 75 73 32 3b 0d 20 20 20 | 20 69 66 20 28 64 69 73 |us2;. | if (dis|
|000016c0| 63 20 3c 20 45 50 53 49 | 4c 4f 4e 29 0d 20 20 20 |c < EPSI|LON). |
|000016d0| 20 20 20 63 6f 6e 74 69 | 6e 75 65 3b 0d 20 20 20 | conti|nue;. |
|000016e0| 20 64 69 73 63 20 3d 20 | 73 71 72 74 28 64 69 73 | disc = |sqrt(dis|
|000016f0| 63 29 3b 0d 20 20 20 20 | 74 31 20 3d 20 62 20 2b |c);. |t1 = b +|
|00001700| 20 64 69 73 63 3b 0d 20 | 20 20 20 69 66 20 28 74 | disc;. | if (t|
|00001710| 31 20 3c 20 6d 69 6e 64 | 69 73 74 29 20 74 31 20 |1 < mind|ist) t1 |
|00001720| 3d 20 30 2e 30 3b 0d 20 | 20 20 20 74 30 20 3d 20 |= 0.0;. | t0 = |
|00001730| 62 20 2d 20 64 69 73 63 | 3b 0d 20 20 20 20 69 66 |b - disc|;. if|
|00001740| 20 28 74 30 20 3c 20 6d | 69 6e 64 69 73 74 29 20 | (t0 < m|indist) |
|00001750| 74 30 20 3d 20 30 2e 30 | 3b 0d 20 20 20 20 69 66 |t0 = 0.0|;. if|
|00001760| 20 28 74 31 20 3d 3d 20 | 74 30 29 20 63 6f 6e 74 | (t1 == |t0) cont|
|00001770| 69 6e 75 65 3b 0d 20 20 | 20 20 65 6c 73 65 20 69 |inue;. | else i|
|00001780| 66 20 28 74 31 20 3c 20 | 74 30 29 20 0d 20 20 20 |f (t1 < |t0) . |
|00001790| 20 20 20 7b 0d 20 20 20 | 20 20 20 64 69 73 63 20 | {. | disc |
|000017a0| 3d 20 74 30 3b 0d 20 20 | 20 20 20 20 74 30 20 3d |= t0;. | t0 =|
|000017b0| 20 74 31 3b 0d 20 20 20 | 20 20 20 74 31 20 3d 20 | t1;. | t1 = |
|000017c0| 64 69 73 63 3b 0d 20 20 | 20 20 20 20 7d 0d 0d 20 |disc;. | }.. |
|000017d0| 20 20 20 2f 2a 20 53 74 | 6f 72 65 20 74 68 65 20 | /* St|ore the |
|000017e0| 70 6f 69 6e 74 73 20 6f | 66 20 69 6e 74 65 72 73 |points o|f inters|
|000017f0| 65 63 74 69 6f 6e 20 6f | 66 20 74 68 69 73 0d 20 |ection o|f this. |
|00001800| 20 20 20 20 20 20 20 20 | 62 6c 6f 62 20 77 69 74 | |blob wit|
|00001810| 68 20 74 68 65 20 72 61 | 79 2e 20 20 4b 65 65 70 |h the ra|y. Keep|
|00001820| 20 74 72 61 63 6b 20 6f | 66 3a 20 77 68 65 74 68 | track o|f: wheth|
|00001830| 65 72 0d 20 20 20 20 20 | 20 20 20 20 74 68 69 73 |er. | this|
|00001840| 20 69 73 20 74 68 65 20 | 73 74 61 72 74 20 6f 72 | is the |start or|
|00001850| 20 65 6e 64 20 70 6f 69 | 6e 74 20 6f 66 20 74 68 | end poi|nt of th|
|00001860| 65 20 68 69 74 2c 0d 20 | 20 20 20 20 20 20 20 20 |e hit,. | |
|00001870| 77 68 69 63 68 20 63 6f | 6d 70 6f 6e 65 6e 74 20 |which co|mponent |
|00001880| 77 61 73 20 70 69 65 72 | 63 65 64 20 62 79 20 74 |was pier|ced by t|
|00001890| 68 65 20 72 61 79 2c 0d | 20 20 20 20 20 20 20 20 |he ray,.| |
|000018a0| 20 61 6e 64 20 74 68 65 | 20 70 6f 69 6e 74 20 61 | and the| point a|
|000018b0| 6c 6f 6e 67 20 74 68 65 | 20 72 61 79 20 74 68 61 |long the| ray tha|
|000018c0| 74 20 74 68 65 0d 20 20 | 20 20 20 20 20 20 20 68 |t the. | h|
|000018d0| 69 74 20 6f 63 63 75 72 | 65 64 20 61 74 2e 20 2a |it occur|ed at. *|
|000018e0| 2f 0d 20 20 20 20 66 6f | 72 20 28 6b 3d 30 3b 6b |/. fo|r (k=0;k|
|000018f0| 3c 63 6e 74 20 26 26 20 | 74 30 20 3e 20 69 6e 74 |<cnt && |t0 > int|
|00001900| 65 72 76 61 6c 73 5b 6b | 5d 2e 62 6f 75 6e 64 3b |ervals[k|].bound;|
|00001910| 6b 2b 2b 29 3b 0d 20 20 | 20 20 69 66 20 28 6b 3c |k++);. | if (k<|
|00001920| 63 6e 74 29 20 0d 20 20 | 20 20 20 20 7b 0d 20 20 |cnt) . | {. |
|00001930| 20 20 20 20 2f 2a 20 54 | 68 69 73 20 68 69 74 20 | /* T|his hit |
|00001940| 70 6f 69 6e 74 20 69 73 | 20 73 6d 61 6c 6c 65 72 |point is| smaller|
|00001950| 20 74 68 61 6e 20 6f 6e | 65 20 74 68 61 74 0d 20 | than on|e that. |
|00001960| 20 20 20 20 20 20 20 20 | 20 20 20 61 6c 72 65 61 | | alrea|
|00001970| 64 79 20 65 78 69 73 74 | 73 20 2d 20 62 75 6d 70 |dy exist|s - bump|
|00001980| 20 74 68 65 20 72 65 73 | 74 20 61 6e 64 20 69 6e | the res|t and in|
|00001990| 73 65 72 74 0d 20 20 20 | 20 20 20 20 20 20 20 20 |sert. | |
|000019a0| 20 69 74 20 68 65 72 65 | 20 2a 2f 0d 20 20 20 20 | it here| */. |
|000019b0| 20 20 66 6f 72 20 28 6a | 3d 63 6e 74 3b 6a 3e 6b | for (j|=cnt;j>k|
|000019c0| 3b 6a 2d 2d 29 0d 20 20 | 20 20 20 20 20 20 6d 65 |;j--). | me|
|000019d0| 6d 63 70 79 28 26 69 6e | 74 65 72 76 61 6c 73 5b |mcpy(&in|tervals[|
|000019e0| 6a 5d 2c 20 26 69 6e 74 | 65 72 76 61 6c 73 5b 6a |j], &int|ervals[j|
|000019f0| 2d 31 5d 2c 0d 20 20 20 | 20 20 20 20 20 20 20 73 |-1],. | s|
|00001a00| 69 7a 65 6f 66 28 42 6c | 6f 62 5f 49 6e 74 65 72 |izeof(Bl|ob_Inter|
|00001a10| 76 61 6c 29 29 3b 0d 20 | 20 20 20 20 20 69 6e 74 |val));. | int|
|00001a20| 65 72 76 61 6c 73 5b 6b | 5d 2e 74 79 70 65 20 20 |ervals[k|].type |
|00001a30| 3d 20 30 3b 0d 20 20 20 | 20 20 20 69 6e 74 65 72 |= 0;. | inter|
|00001a40| 76 61 6c 73 5b 6b 5d 2e | 69 6e 64 65 78 20 3d 20 |vals[k].|index = |
|00001a50| 69 3b 0d 20 20 20 20 20 | 20 69 6e 74 65 72 76 61 |i;. | interva|
|00001a60| 6c 73 5b 6b 5d 2e 62 6f | 75 6e 64 20 3d 20 74 30 |ls[k].bo|und = t0|
|00001a70| 3b 0d 20 20 20 20 20 20 | 63 6e 74 2b 2b 3b 0d 20 |;. |cnt++;. |
|00001a80| 20 20 20 20 20 66 6f 72 | 20 28 6b 3d 6b 2b 31 3b | for| (k=k+1;|
|00001a90| 6b 3c 63 6e 74 20 26 26 | 20 74 31 20 3e 20 69 6e |k<cnt &&| t1 > in|
|00001aa0| 74 65 72 76 61 6c 73 5b | 6b 5d 2e 62 6f 75 6e 64 |tervals[|k].bound|
|00001ab0| 3b 6b 2b 2b 29 3b 0d 20 | 20 20 20 20 20 69 66 20 |;k++);. | if |
|00001ac0| 28 6b 3c 63 6e 74 29 20 | 0d 20 20 20 20 20 20 20 |(k<cnt) |. |
|00001ad0| 20 7b 0d 20 20 20 20 20 | 20 20 20 66 6f 72 20 28 | {. | for (|
|00001ae0| 6a 3d 63 6e 74 3b 6a 3e | 6b 3b 6a 2d 2d 29 0d 20 |j=cnt;j>|k;j--). |
|00001af0| 20 20 20 20 20 20 20 20 | 20 6d 65 6d 63 70 79 28 | | memcpy(|
|00001b00| 26 69 6e 74 65 72 76 61 | 6c 73 5b 6a 5d 2c 20 26 |&interva|ls[j], &|
|00001b10| 69 6e 74 65 72 76 61 6c | 73 5b 6a 2d 31 5d 2c 0d |interval|s[j-1],.|
|00001b20| 20 20 20 20 20 20 20 20 | 20 20 20 20 73 69 7a 65 | | size|
|00001b30| 6f 66 28 42 6c 6f 62 5f | 49 6e 74 65 72 76 61 6c |of(Blob_|Interval|
|00001b40| 29 29 3b 0d 20 20 20 20 | 20 20 20 20 69 6e 74 65 |));. | inte|
|00001b50| 72 76 61 6c 73 5b 6b 5d | 2e 74 79 70 65 20 20 3d |rvals[k]|.type =|
|00001b60| 20 31 3b 0d 20 20 20 20 | 20 20 20 20 69 6e 74 65 | 1;. | inte|
|00001b70| 72 76 61 6c 73 5b 6b 5d | 2e 69 6e 64 65 78 20 3d |rvals[k]|.index =|
|00001b80| 20 69 3b 0d 20 20 20 20 | 20 20 20 20 69 6e 74 65 | i;. | inte|
|00001b90| 72 76 61 6c 73 5b 6b 5d | 2e 62 6f 75 6e 64 20 3d |rvals[k]|.bound =|
|00001ba0| 20 74 31 3b 0d 20 20 20 | 20 20 20 20 20 7d 0d 20 | t1;. | }. |
|00001bb0| 20 20 20 20 20 65 6c 73 | 65 20 0d 20 20 20 20 20 | els|e . |
|00001bc0| 20 20 20 7b 0d 20 20 20 | 20 20 20 20 20 69 6e 74 | {. | int|
|00001bd0| 65 72 76 61 6c 73 5b 63 | 6e 74 5d 2e 74 79 70 65 |ervals[c|nt].type|
|00001be0| 20 20 3d 20 31 3b 0d 20 | 20 20 20 20 20 20 20 69 | = 1;. | i|
|00001bf0| 6e 74 65 72 76 61 6c 73 | 5b 63 6e 74 5d 2e 69 6e |ntervals|[cnt].in|
|00001c00| 64 65 78 20 3d 20 69 3b | 0d 20 20 20 20 20 20 20 |dex = i;|. |
|00001c10| 20 69 6e 74 65 72 76 61 | 6c 73 5b 63 6e 74 5d 2e | interva|ls[cnt].|
|00001c20| 62 6f 75 6e 64 20 3d 20 | 74 31 3b 0d 20 20 20 20 |bound = |t1;. |
|00001c30| 20 20 20 20 7d 0d 20 20 | 20 20 20 20 63 6e 74 2b | }. | cnt+|
|00001c40| 2b 3b 0d 20 20 20 20 20 | 20 7d 0d 20 20 20 20 65 |+;. | }. e|
|00001c50| 6c 73 65 20 0d 20 20 20 | 20 20 20 7b 0d 20 20 20 |lse . | {. |
|00001c60| 20 20 20 2f 2a 20 4a 75 | 73 74 20 70 6c 6f 70 20 | /* Ju|st plop |
|00001c70| 74 68 65 20 73 74 61 72 | 74 20 61 6e 64 20 65 6e |the star|t and en|
|00001c80| 64 20 70 6f 69 6e 74 73 | 20 61 74 0d 20 20 20 20 |d points| at. |
|00001c90| 20 20 20 20 20 20 20 20 | 74 68 65 20 65 6e 64 20 | |the end |
|00001ca0| 6f 66 20 74 68 65 20 6c | 69 73 74 20 2a 2f 0d 20 |of the l|ist */. |
|00001cb0| 20 20 20 20 20 69 6e 74 | 65 72 76 61 6c 73 5b 63 | int|ervals[c|
|00001cc0| 6e 74 5d 2e 74 79 70 65 | 20 20 3d 20 30 3b 0d 20 |nt].type| = 0;. |
|00001cd0| 20 20 20 20 20 69 6e 74 | 65 72 76 61 6c 73 5b 63 | int|ervals[c|
|00001ce0| 6e 74 5d 2e 69 6e 64 65 | 78 20 3d 20 69 3b 0d 20 |nt].inde|x = i;. |
|00001cf0| 20 20 20 20 20 69 6e 74 | 65 72 76 61 6c 73 5b 63 | int|ervals[c|
|00001d00| 6e 74 5d 2e 62 6f 75 6e | 64 20 3d 20 74 30 3b 0d |nt].boun|d = t0;.|
|00001d10| 20 20 20 20 20 20 63 6e | 74 2b 2b 3b 0d 20 20 20 | cn|t++;. |
|00001d20| 20 20 20 69 6e 74 65 72 | 76 61 6c 73 5b 63 6e 74 | inter|vals[cnt|
|00001d30| 5d 2e 74 79 70 65 20 20 | 3d 20 31 3b 0d 20 20 20 |].type |= 1;. |
|00001d40| 20 20 20 69 6e 74 65 72 | 76 61 6c 73 5b 63 6e 74 | inter|vals[cnt|
|00001d50| 5d 2e 69 6e 64 65 78 20 | 3d 20 69 3b 0d 20 20 20 |].index |= i;. |
|00001d60| 20 20 20 69 6e 74 65 72 | 76 61 6c 73 5b 63 6e 74 | inter|vals[cnt|
|00001d70| 5d 2e 62 6f 75 6e 64 20 | 3d 20 74 31 3b 0d 20 20 |].bound |= t1;. |
|00001d80| 20 20 20 20 63 6e 74 2b | 2b 3b 0d 20 20 20 20 20 | cnt+|+;. |
|00001d90| 20 7d 0d 20 20 20 20 7d | 0d 20 20 72 65 74 75 72 | }. }|. retur|
|00001da0| 6e 20 63 6e 74 3b 0d 20 | 20 7d 0d 0d 20 20 2f 2a |n cnt;. | }.. /*|
|00001db0| 20 43 61 6c 63 75 6c 61 | 74 65 20 74 68 65 20 66 | Calcula|te the f|
|00001dc0| 69 65 6c 64 20 76 61 6c | 75 65 20 6f 66 20 61 20 |ield val|ue of a |
|00001dd0| 62 6c 6f 62 20 2d 20 74 | 68 65 20 70 6f 73 69 74 |blob - t|he posit|
|00001de0| 69 6f 6e 20 76 65 63 74 | 6f 72 0d 20 20 20 22 50 |ion vect|or. "P|
|00001df0| 6f 73 22 20 6d 75 73 74 | 20 61 6c 72 65 61 64 79 |os" must| already|
|00001e00| 20 68 61 76 65 20 62 65 | 65 6e 20 74 72 61 6e 73 | have be|en trans|
|00001e10| 66 6f 72 6d 65 64 20 69 | 6e 74 6f 20 62 6c 6f 62 |formed i|nto blob|
|00001e20| 20 73 70 61 63 65 2e 20 | 2a 2f 0d 20 20 73 74 61 | space. |*/. sta|
|00001e30| 74 69 63 20 44 42 4c 0d | 20 20 63 61 6c 63 75 6c |tic DBL.| calcul|
|00001e40| 61 74 65 5f 66 69 65 6c | 64 5f 76 61 6c 75 65 28 |ate_fiel|d_value(|
|00001e50| 6f 62 6a 2c 20 50 6f 73 | 29 0d 20 20 20 20 4f 42 |obj, Pos|). OB|
|00001e60| 4a 45 43 54 20 2a 6f 62 | 6a 3b 0d 56 45 43 54 4f |JECT *ob|j;.VECTO|
|00001e70| 52 20 2a 50 6f 73 3b 0d | 20 20 7b 0d 20 20 69 6e |R *Pos;.| {. in|
|00001e80| 74 20 69 3b 0d 20 20 44 | 42 4c 20 6c 65 6e 2c 20 |t i;. D|BL len, |
|00001e90| 64 65 6e 73 69 74 79 3b | 0d 20 20 56 45 43 54 4f |density;|. VECTO|
|00001ea0| 52 20 56 3b 0d 20 20 42 | 6c 6f 62 5f 45 6c 65 6d |R V;. B|lob_Elem|
|00001eb0| 65 6e 74 20 2a 70 74 72 | 3b 0d 20 20 42 4c 4f 42 |ent *ptr|;. BLOB|
|00001ec0| 20 2a 62 6c 6f 62 20 3d | 20 28 42 4c 4f 42 20 2a | *blob =| (BLOB *|
|00001ed0| 29 6f 62 6a 3b 0d 0d 20 | 20 64 65 6e 73 69 74 79 |)obj;.. | density|
|00001ee0| 20 3d 20 30 2e 30 3b 0d | 20 20 66 6f 72 20 28 69 | = 0.0;.| for (i|
|00001ef0| 3d 30 3b 69 3c 62 6c 6f | 62 2d 3e 63 6f 75 6e 74 |=0;i<blo|b->count|
|00001f00| 3b 69 2b 2b 29 20 0d 20 | 20 20 20 7b 0d 20 20 20 |;i++) . | {. |
|00001f10| 20 70 74 72 20 3d 20 62 | 6c 6f 62 2d 3e 6c 69 73 | ptr = b|lob->lis|
|00001f20| 74 5b 69 5d 3b 0d 20 20 | 20 20 56 53 75 62 28 56 |t[i];. | VSub(V|
|00001f30| 2c 20 70 74 72 2d 3e 70 | 6f 73 2c 20 2a 50 6f 73 |, ptr->p|os, *Pos|
|00001f40| 29 3b 0d 20 20 20 20 56 | 44 6f 74 28 6c 65 6e 2c |);. V|Dot(len,|
|00001f50| 20 56 2c 20 56 29 3b 0d | 20 20 20 20 69 66 20 28 | V, V);.| if (|
|00001f60| 6c 65 6e 20 3c 20 70 74 | 72 2d 3e 72 61 64 69 75 |len < pt|r->radiu|
|00001f70| 73 32 29 20 0d 20 20 20 | 20 20 20 7b 0d 20 20 20 |s2) . | {. |
|00001f80| 20 20 20 2f 2a 20 49 6e | 73 69 64 65 20 74 68 65 | /* In|side the|
|00001f90| 20 72 61 64 69 75 73 20 | 6f 66 20 69 6e 66 6c 75 | radius |of influ|
|00001fa0| 65 6e 63 65 20 6f 66 20 | 74 68 69 73 0d 20 20 20 |ence of |this. |
|00001fb0| 20 20 20 20 20 20 20 20 | 20 63 6f 6d 70 6f 6e 65 | | compone|
|00001fc0| 6e 74 2c 20 61 64 64 20 | 69 74 27 73 20 63 6f 6e |nt, add |it's con|
|00001fd0| 74 72 69 62 75 74 69 6f | 6e 20 2a 2f 0d 20 20 20 |tributio|n */. |
|00001fe0| 20 20 20 64 65 6e 73 69 | 74 79 20 2b 3d 20 6c 65 | densi|ty += le|
|00001ff0| 6e 20 2a 20 28 6c 65 6e | 20 2a 20 70 74 72 2d 3e |n * (len| * ptr->|
|00002000| 63 6f 65 66 66 73 5b 30 | 5d 20 2b 0d 20 20 20 20 |coeffs[0|] +. |
|00002010| 20 20 20 20 70 74 72 2d | 3e 63 6f 65 66 66 73 5b | ptr-|>coeffs[|
|00002020| 31 5d 29 20 2b 0d 20 20 | 20 20 20 20 70 74 72 2d |1]) +. | ptr-|
|00002030| 3e 63 6f 65 66 66 73 5b | 32 5d 3b 0d 20 20 20 20 |>coeffs[|2];. |
|00002040| 20 20 7d 0d 20 20 20 20 | 7d 0d 20 20 72 65 74 75 | }. |}. retu|
|00002050| 72 6e 20 64 65 6e 73 69 | 74 79 3b 0d 20 20 7d 0d |rn densi|ty;. }.|
|00002060| 0d 2f 2a 20 47 65 6e 65 | 72 61 74 65 20 69 6e 74 |./* Gene|rate int|
|00002070| 65 72 76 61 6c 73 20 6f | 66 20 69 6e 66 6c 75 65 |ervals o|f influe|
|00002080| 6e 63 65 20 6f 66 20 65 | 61 63 68 20 63 6f 6d 70 |nce of e|ach comp|
|00002090| 6f 6e 65 6e 74 2e 20 20 | 41 66 74 65 72 20 74 68 |onent. |After th|
|000020a0| 65 73 65 0d 20 20 20 61 | 72 65 20 6d 61 64 65 2c |ese. a|re made,|
|000020b0| 20 64 65 74 65 72 6d 69 | 6e 65 20 74 68 65 69 72 | determi|ne their|
|000020c0| 20 61 67 67 72 65 67 61 | 74 65 20 65 66 66 65 63 | aggrega|te effec|
|000020d0| 74 20 6f 6e 20 74 68 65 | 20 72 61 79 2e 20 20 41 |t on the| ray. A|
|000020e0| 73 20 74 68 65 0d 20 20 | 20 69 6e 64 69 76 69 64 |s the. | individ|
|000020f0| 75 61 6c 20 69 6e 74 65 | 72 76 61 6c 73 20 61 72 |ual inte|rvals ar|
|00002100| 65 20 63 68 65 63 6b 65 | 64 2c 20 61 20 71 75 61 |e checke|d, a qua|
|00002110| 72 74 69 63 20 69 73 20 | 67 65 6e 65 72 61 74 65 |rtic is |generate|
|00002120| 64 0d 20 20 20 74 68 61 | 74 20 72 65 70 72 65 73 |d. tha|t repres|
|00002130| 65 6e 74 73 20 74 68 65 | 20 64 65 6e 73 69 74 79 |ents the| density|
|00002140| 20 61 74 20 61 20 70 61 | 72 74 69 63 75 6c 61 72 | at a pa|rticular|
|00002150| 20 70 6f 69 6e 74 20 6f | 6e 20 74 68 65 20 72 61 | point o|n the ra|
|00002160| 79 2e 0d 0d 20 20 20 41 | 66 74 65 72 20 6d 61 6b |y... A|fter mak|
|00002170| 69 6e 67 20 74 68 65 20 | 73 75 62 73 74 69 74 75 |ing the |substitu|
|00002180| 74 69 6f 6e 73 20 69 6e | 20 4d 61 6b 65 42 6c 6f |tions in| MakeBlo|
|00002190| 62 2c 20 74 68 65 72 65 | 20 69 73 20 61 20 66 6f |b, there| is a fo|
|000021a0| 72 6d 75 6c 61 0d 20 20 | 20 66 6f 72 20 65 61 63 |rmula. | for eac|
|000021b0| 68 20 63 6f 6d 70 6f 6e | 65 6e 74 20 74 68 61 74 |h compon|ent that|
|000021c0| 20 68 61 73 20 74 68 65 | 20 66 6f 72 6d 3a 0d 20 | has the| form:. |
|000021d0| 20 20 0d 20 20 20 20 20 | 20 63 30 20 2a 20 72 5e | . | c0 * r^|
|000021e0| 34 20 2b 20 63 31 20 2a | 20 72 5e 32 20 2b 20 63 |4 + c1 *| r^2 + c|
|000021f0| 32 2e 0d 20 20 20 0d 20 | 20 20 49 6e 20 6f 72 64 |2.. . | In ord|
|00002200| 65 72 20 74 6f 20 64 65 | 74 65 72 6d 69 6e 65 20 |er to de|termine |
|00002210| 74 68 65 20 69 6e 66 6c | 75 65 6e 63 65 20 6f 6e |the infl|uence on|
|00002220| 20 74 68 65 20 72 61 79 | 20 6f 66 20 61 6c 6c 20 | the ray| of all |
|00002230| 6f 66 20 74 68 65 0d 20 | 20 20 69 6e 64 69 76 69 |of the. | indivi|
|00002240| 64 75 61 6c 20 63 6f 6d | 70 6f 6e 65 6e 74 73 2c |dual com|ponents,|
|00002250| 20 77 65 20 73 74 61 72 | 74 20 62 79 20 64 65 74 | we star|t by det|
|00002260| 65 72 6d 69 6e 69 6e 67 | 20 74 68 65 20 64 69 73 |ermining| the dis|
|00002270| 74 61 6e 63 65 0d 20 20 | 20 66 72 6f 6d 20 61 6e |tance. | from an|
|00002280| 79 20 70 6f 69 6e 74 20 | 6f 6e 20 74 68 65 20 72 |y point |on the r|
|00002290| 61 79 20 74 6f 20 74 68 | 65 20 73 70 65 63 69 66 |ay to th|e specif|
|000022a0| 69 65 64 20 70 6f 69 6e | 74 2e 20 20 54 68 69 73 |ied poin|t. This|
|000022b0| 20 63 61 6e 0d 20 20 20 | 62 65 20 66 6f 75 6e 64 | can. |be found|
|000022c0| 20 75 73 69 6e 67 20 74 | 68 65 20 70 79 74 68 61 | using t|he pytha|
|000022d0| 67 6f 72 65 61 6e 20 74 | 68 65 6f 72 65 6d 2c 20 |gorean t|heorem, |
|000022e0| 75 73 69 6e 67 20 43 20 | 61 73 20 74 68 65 20 63 |using C |as the c|
|000022f0| 65 6e 74 65 72 0d 20 20 | 20 6f 66 20 74 68 69 73 |enter. | of this|
|00002300| 20 63 6f 6d 70 6f 6e 65 | 6e 74 2c 20 50 20 61 73 | compone|nt, P as|
|00002310| 20 74 68 65 20 73 74 61 | 72 74 20 6f 66 20 74 68 | the sta|rt of th|
|00002320| 65 20 72 61 79 2c 20 61 | 6e 64 20 44 20 61 73 20 |e ray, a|nd D as |
|00002330| 74 68 65 0d 20 20 20 64 | 69 72 65 63 74 69 6f 6e |the. d|irection|
|00002340| 20 6f 66 20 74 72 61 76 | 65 6c 20 6f 66 20 74 68 | of trav|el of th|
|00002350| 65 20 72 61 79 3a 0d 0d | 20 20 20 20 20 20 72 5e |e ray:..| r^|
|00002360| 32 20 3d 20 28 74 20 2a | 20 44 20 2b 20 50 20 2d |2 = (t *| D + P -|
|00002370| 20 43 29 20 2e 20 28 74 | 20 2a 20 44 20 2b 20 50 | C) . (t| * D + P|
|00002380| 20 2d 20 43 29 0d 0d 20 | 20 20 77 65 20 69 6e 73 | - C).. | we ins|
|00002390| 65 72 74 20 74 68 69 73 | 20 65 71 75 61 74 69 6f |ert this| equatio|
|000023a0| 6e 20 66 6f 72 20 65 61 | 63 68 20 61 70 70 65 61 |n for ea|ch appea|
|000023b0| 72 61 6e 63 65 20 6f 66 | 20 72 5e 32 20 69 6e 20 |rance of| r^2 in |
|000023c0| 74 68 65 0d 20 20 20 63 | 6f 6d 70 6f 6e 65 6e 74 |the. c|omponent|
|000023d0| 73 27 20 66 6f 72 6d 75 | 6c 61 2c 20 67 69 76 69 |s' formu|la, givi|
|000023e0| 6e 67 3a 0d 0d 20 20 20 | 20 20 20 72 5e 32 20 3d |ng:.. | r^2 =|
|000023f0| 20 44 2e 44 20 74 5e 32 | 20 2b 20 32 20 74 20 44 | D.D t^2| + 2 t D|
|00002400| 20 2e 20 28 50 20 2d 20 | 43 29 20 2b 20 28 50 20 | . (P - |C) + (P |
|00002410| 2d 20 43 29 20 2e 20 28 | 50 20 2d 20 43 29 0d 0d |- C) . (|P - C)..|
|00002420| 20 20 20 53 69 6e 63 65 | 20 74 68 65 20 64 69 72 | Since| the dir|
|00002430| 65 63 74 69 6f 6e 20 76 | 65 63 74 6f 72 20 68 61 |ection v|ector ha|
|00002440| 73 20 62 65 65 6e 20 6e | 6f 72 6d 61 6c 69 7a 65 |s been n|ormalize|
|00002450| 64 2c 20 44 2e 44 20 3d | 20 31 2e 0d 20 20 20 55 |d, D.D =| 1.. U|
|00002460| 73 69 6e 67 20 74 68 65 | 20 73 75 62 73 74 69 74 |sing the| substit|
|00002470| 75 74 69 6f 6e 73 3a 0d | 0d 20 20 20 20 20 20 74 |utions:.|. t|
|00002480| 30 20 3d 20 28 50 20 2d | 20 43 29 20 2e 20 28 50 |0 = (P -| C) . (P|
|00002490| 20 2d 20 43 29 2c 0d 20 | 20 20 20 20 20 74 31 20 | - C),. | t1 |
|000024a0| 3d 20 44 20 2e 20 28 50 | 20 2d 20 43 29 0d 0d 20 |= D . (P| - C).. |
|000024b0| 20 20 57 65 20 63 61 6e | 20 77 72 69 74 65 20 74 | We can| write t|
|000024c0| 68 65 20 66 6f 72 6d 75 | 6c 61 20 61 73 3a 0d 0d |he formu|la as:..|
|000024d0| 20 20 20 20 20 20 72 5e | 32 20 3d 20 74 30 20 2b | r^|2 = t0 +|
|000024e0| 20 32 20 74 20 74 31 20 | 2b 20 74 5e 32 0d 0d 20 | 2 t t1 |+ t^2.. |
|000024f0| 20 20 54 61 6b 69 6e 67 | 20 72 5e 32 20 61 6e 64 | Taking| r^2 and|
|00002500| 20 73 75 62 73 74 69 74 | 75 74 69 6e 67 20 69 6e | substit|uting in|
|00002510| 74 6f 20 74 68 65 20 66 | 6f 72 6d 75 6c 61 20 66 |to the f|ormula f|
|00002520| 6f 72 20 74 68 69 73 20 | 63 6f 6d 70 6f 6e 65 6e |or this |componen|
|00002530| 74 0d 20 20 20 6f 66 20 | 74 68 65 20 62 6c 6f 62 |t. of |the blob|
|00002540| 20 77 65 20 67 65 74 20 | 74 68 65 20 66 6f 72 6d | we get |the form|
|00002550| 75 6c 61 3a 0d 0d 20 20 | 20 20 20 20 64 65 6e 73 |ula:.. | dens|
|00002560| 69 74 79 20 3d 20 63 30 | 20 2a 20 28 72 5e 32 29 |ity = c0| * (r^2)|
|00002570| 5e 32 20 2b 20 63 31 20 | 2a 20 72 5e 32 20 2b 20 |^2 + c1 |* r^2 + |
|00002580| 63 32 2c 0d 0d 20 20 20 | 6f 72 3a 0d 0d 20 20 20 |c2,.. |or:.. |
|00002590| 20 20 20 64 65 6e 73 69 | 74 79 20 3d 20 63 30 20 | densi|ty = c0 |
|000025a0| 2a 20 28 74 30 20 2b 20 | 32 20 74 20 74 31 20 2b |* (t0 + |2 t t1 +|
|000025b0| 20 74 5e 32 29 5e 32 20 | 2b 0d 20 20 20 20 20 20 | t^2)^2 |+. |
|000025c0| 20 20 20 20 20 20 20 20 | 20 20 63 31 20 2a 20 28 | | c1 * (|
|000025d0| 74 30 20 2b 20 32 20 74 | 20 74 31 20 2b 20 74 5e |t0 + 2 t| t1 + t^|
|000025e0| 32 29 20 2b 0d 20 20 20 | 20 20 20 20 20 20 20 20 |2) +. | |
|000025f0| 20 20 20 20 20 63 32 0d | 0d 20 20 20 45 78 70 61 | c2.|. Expa|
|00002600| 6e 64 69 6e 67 20 74 65 | 72 6d 73 20 61 6e 64 20 |nding te|rms and |
|00002610| 63 6f 6c 6c 65 63 74 69 | 6e 67 20 77 69 74 68 20 |collecti|ng with |
|00002620| 72 65 73 70 65 63 74 20 | 74 6f 20 22 74 22 20 67 |respect |to "t" g|
|00002630| 69 76 65 73 3a 0d 20 20 | 20 20 20 20 74 5e 34 20 |ives:. | t^4 |
|00002640| 2a 20 63 30 20 2b 0d 20 | 20 20 20 20 20 74 5e 33 |* c0 +. | t^3|
|00002650| 20 2a 20 34 20 63 30 20 | 74 31 20 2b 0d 20 20 20 | * 4 c0 |t1 +. |
|00002660| 20 20 20 74 5e 32 20 2a | 20 28 63 31 20 2b 20 32 | t^2 *| (c1 + 2|
|00002670| 20 2a 20 63 30 20 74 30 | 20 2b 20 34 20 63 30 20 | * c0 t0| + 4 c0 |
|00002680| 74 31 5e 32 29 0d 20 20 | 20 20 20 20 74 20 20 20 |t1^2). | t |
|00002690| 2a 20 32 20 28 63 31 20 | 74 31 20 2b 20 32 20 63 |* 2 (c1 |t1 + 2 c|
|000026a0| 30 20 74 30 20 74 31 29 | 20 2b 0d 20 20 20 20 20 |0 t0 t1)| +. |
|000026b0| 20 20 20 20 20 20 20 63 | 32 20 2b 20 63 31 2a 74 | c|2 + c1*t|
|000026c0| 30 20 2b 20 63 30 2a 74 | 30 5e 32 0d 0d 20 20 20 |0 + c0*t|0^2.. |
|000026d0| 54 68 69 73 20 66 6f 72 | 6d 75 6c 61 20 63 61 6e |This for|mula can|
|000026e0| 20 6e 6f 77 20 62 65 20 | 73 6f 6c 76 65 64 20 66 | now be |solved f|
|000026f0| 6f 72 20 22 74 22 20 62 | 79 20 61 6e 79 20 6f 66 |or "t" b|y any of|
|00002700| 20 74 68 65 20 71 75 61 | 72 74 69 63 0d 20 20 20 | the qua|rtic. |
|00002710| 72 6f 6f 74 20 73 6f 6c | 76 65 72 73 20 74 68 61 |root sol|vers tha|
|00002720| 74 20 61 72 65 20 61 76 | 61 69 6c 61 62 6c 65 2e |t are av|ailable.|
|00002730| 0d 2a 2f 0d 69 6e 74 20 | 41 6c 6c 5f 42 6c 6f 62 |.*/.int |All_Blob|
|00002740| 5f 49 6e 74 65 72 73 65 | 63 74 69 6f 6e 73 28 4f |_Interse|ctions(O|
|00002750| 62 6a 65 63 74 2c 20 52 | 61 79 2c 20 44 65 70 74 |bject, R|ay, Dept|
|00002760| 68 5f 53 74 61 63 6b 29 | 0d 4f 42 4a 45 43 54 20 |h_Stack)|.OBJECT |
|00002770| 2a 4f 62 6a 65 63 74 3b | 0d 52 41 59 20 2a 52 61 |*Object;|.RAY *Ra|
|00002780| 79 3b 0d 49 53 54 41 43 | 4b 20 2a 44 65 70 74 68 |y;.ISTAC|K *Depth|
|00002790| 5f 53 74 61 63 6b 3b 0d | 20 20 7b 0d 20 20 42 4c |_Stack;.| {. BL|
|000027a0| 4f 42 20 2a 62 6c 6f 62 | 20 3d 20 28 42 4c 4f 42 |OB *blob| = (BLOB|
|000027b0| 20 2a 29 4f 62 6a 65 63 | 74 3b 0d 20 20 44 42 4c | *)Objec|t;. DBL|
|000027c0| 20 64 69 73 74 2c 20 6c | 65 6e 2c 20 2a 74 63 6f | dist, l|en, *tco|
|000027d0| 65 66 66 73 2c 20 63 6f | 65 66 66 73 5b 35 5d 2c |effs, co|effs[5],|
|000027e0| 20 72 6f 6f 74 73 5b 34 | 5d 3b 0d 20 20 69 6e 74 | roots[4|];. int|
|000027f0| 20 69 2c 20 6a 2c 20 63 | 6e 74 3b 0d 20 20 56 45 | i, j, c|nt;. VE|
|00002800| 43 54 4f 52 20 50 2c 20 | 44 2c 20 56 3b 0d 20 20 |CTOR P, |D, V;. |
|00002810| 69 6e 74 20 72 6f 6f 74 | 5f 63 6f 75 6e 74 2c 20 |int root|_count, |
|00002820| 69 6e 5f 66 6c 61 67 3b | 0d 20 20 42 6c 6f 62 5f |in_flag;|. Blob_|
|00002830| 45 6c 65 6d 65 6e 74 20 | 2a 65 6c 65 6d 65 6e 74 |Element |*element|
|00002840| 3b 0d 20 20 44 42 4c 20 | 74 30 2c 20 74 31 2c 20 |;. DBL |t0, t1, |
|00002850| 63 30 2c 20 63 31 2c 20 | 63 32 3b 0d 20 20 56 45 |c0, c1, |c2;. VE|
|00002860| 43 54 4f 52 20 49 50 6f | 69 6e 74 2c 20 64 76 3b |CTOR IPo|int, dv;|
|00002870| 0d 20 20 42 6c 6f 62 5f | 49 6e 74 65 72 76 61 6c |. Blob_|Interval|
|00002880| 20 2a 69 6e 74 65 72 76 | 61 6c 73 20 3d 20 62 6c | *interv|als = bl|
|00002890| 6f 62 2d 3e 69 6e 74 65 | 72 76 61 6c 73 3b 0d 20 |ob->inte|rvals;. |
|000028a0| 20 69 6e 74 20 49 6e 74 | 65 72 73 65 63 74 69 6f | int Int|ersectio|
|000028b0| 6e 5f 46 6f 75 6e 64 20 | 3d 20 46 41 4c 53 45 3b |n_Found |= FALSE;|
|000028c0| 0d 0d 20 20 52 61 79 5f | 42 6c 6f 62 5f 54 65 73 |.. Ray_|Blob_Tes|
|000028d0| 74 73 2b 2b 3b 0d 0d 20 | 20 2f 2a 20 54 72 61 6e |ts++;.. | /* Tran|
|000028e0| 73 66 6f 72 6d 20 74 68 | 65 20 72 61 79 20 69 6e |sform th|e ray in|
|000028f0| 74 6f 20 74 68 65 20 62 | 6c 6f 62 20 73 70 61 63 |to the b|lob spac|
|00002900| 65 20 2a 2f 0d 20 20 69 | 66 20 28 62 6c 6f 62 2d |e */. i|f (blob-|
|00002910| 3e 54 72 61 6e 73 20 21 | 3d 20 4e 55 4c 4c 29 20 |>Trans !|= NULL) |
|00002920| 0d 20 20 20 20 7b 0d 20 | 20 20 20 4d 49 6e 76 54 |. {. | MInvT|
|00002930| 72 61 6e 73 50 6f 69 6e | 74 28 26 50 2c 20 26 52 |ransPoin|t(&P, &R|
|00002940| 61 79 2d 3e 49 6e 69 74 | 69 61 6c 2c 20 62 6c 6f |ay->Init|ial, blo|
|00002950| 62 2d 3e 54 72 61 6e 73 | 29 3b 0d 20 20 20 20 4d |b->Trans|);. M|
|00002960| 49 6e 76 54 72 61 6e 73 | 44 69 72 65 63 74 69 6f |InvTrans|Directio|
|00002970| 6e 28 26 44 2c 20 26 52 | 61 79 2d 3e 44 69 72 65 |n(&D, &R|ay->Dire|
|00002980| 63 74 69 6f 6e 2c 20 62 | 6c 6f 62 2d 3e 54 72 61 |ction, b|lob->Tra|
|00002990| 6e 73 29 3b 0d 20 20 20 | 20 7d 0d 20 20 65 6c 73 |ns);. | }. els|
|000029a0| 65 20 0d 20 20 20 20 7b | 0d 20 20 20 20 50 20 3d |e . {|. P =|
|000029b0| 20 52 61 79 2d 3e 49 6e | 69 74 69 61 6c 3b 0d 20 | Ray->In|itial;. |
|000029c0| 20 20 20 44 20 3d 20 52 | 61 79 2d 3e 44 69 72 65 | D = R|ay->Dire|
|000029d0| 63 74 69 6f 6e 3b 0d 20 | 20 20 20 7d 0d 0d 20 20 |ction;. | }.. |
|000029e0| 20 20 6c 65 6e 20 3d 20 | 73 71 72 74 28 44 2e 78 | len = |sqrt(D.x|
|000029f0| 20 2a 20 44 2e 78 20 2b | 20 44 2e 79 20 2a 20 44 | * D.x +| D.y * D|
|00002a00| 2e 79 20 2b 20 44 2e 7a | 20 2a 20 44 2e 7a 29 3b |.y + D.z| * D.z);|
|00002a10| 0d 20 20 69 66 20 28 6c | 65 6e 20 3d 3d 20 30 2e |. if (l|en == 0.|
|00002a20| 30 29 0d 20 20 20 20 72 | 65 74 75 72 6e 20 30 3b |0). r|eturn 0;|
|00002a30| 0d 20 20 65 6c 73 65 20 | 0d 20 20 20 20 7b 0d 20 |. else |. {. |
|00002a40| 20 20 20 44 2e 78 20 2f | 3d 20 6c 65 6e 3b 0d 20 | D.x /|= len;. |
|00002a50| 20 20 20 44 2e 79 20 2f | 3d 20 6c 65 6e 3b 0d 20 | D.y /|= len;. |
|00002a60| 20 20 20 44 2e 7a 20 2f | 3d 20 6c 65 6e 3b 0d 20 | D.z /|= len;. |
|00002a70| 20 20 20 7d 0d 0d 20 20 | 20 20 2f 2a 20 46 69 67 | }.. | /* Fig|
|00002a80| 75 72 65 20 6f 75 74 20 | 74 68 65 20 69 6e 74 65 |ure out |the inte|
|00002a90| 72 76 61 6c 73 20 61 6c | 6f 6e 67 20 74 68 65 20 |rvals al|ong the |
|00002aa0| 72 61 79 20 77 68 65 72 | 65 20 65 61 63 68 0d 20 |ray wher|e each. |
|00002ab0| 20 20 63 6f 6d 70 6f 6e | 65 6e 74 20 6f 66 20 74 | compon|ent of t|
|00002ac0| 68 65 20 62 6c 6f 62 20 | 68 61 73 20 61 6e 20 65 |he blob |has an e|
|00002ad0| 66 66 65 63 74 2e 20 2a | 2f 0d 20 20 20 20 69 66 |ffect. *|/. if|
|00002ae0| 20 28 28 63 6e 74 20 3d | 20 64 65 74 65 72 6d 69 | ((cnt =| determi|
|00002af0| 6e 65 5f 69 6e 66 6c 75 | 65 6e 63 65 73 28 26 50 |ne_influ|ences(&P|
|00002b00| 2c 20 26 44 2c 20 62 6c | 6f 62 2c 20 30 2e 30 31 |, &D, bl|ob, 0.01|
|00002b10| 29 29 20 3d 3d 20 30 29 | 0d 20 20 20 20 20 20 2f |)) == 0)|. /|
|00002b20| 2a 20 52 61 79 20 64 6f | 65 73 6e 27 74 20 68 69 |* Ray do|esn't hi|
|00002b30| 74 20 74 68 65 20 73 70 | 68 65 72 65 20 6f 66 20 |t the sp|here of |
|00002b40| 69 6e 66 6c 75 65 6e 63 | 65 20 6f 66 20 61 6e 79 |influenc|e of any|
|00002b50| 20 6f 66 0d 20 20 20 20 | 20 20 69 74 73 20 63 6f | of. | its co|
|00002b60| 6d 70 6f 6e 65 6e 74 20 | 65 6c 65 6d 65 6e 74 73 |mponent |elements|
|00002b70| 20 2a 2f 0d 20 20 20 20 | 20 20 72 65 74 75 72 6e | */. | return|
|00002b80| 20 30 3b 0d 0d 20 20 2f | 2a 20 43 6c 65 61 72 20 | 0;.. /|* Clear |
|00002b90| 6f 75 74 20 74 68 65 20 | 63 6f 65 66 66 69 63 69 |out the |coeffici|
|00002ba0| 65 6e 74 73 20 2a 2f 0d | 20 20 66 6f 72 20 28 69 |ents */.| for (i|
|00002bb0| 3d 30 3b 69 3c 34 3b 69 | 2b 2b 29 20 63 6f 65 66 |=0;i<4;i|++) coef|
|00002bc0| 66 73 5b 69 5d 20 3d 20 | 30 2e 30 3b 0d 20 20 63 |fs[i] = |0.0;. c|
|00002bd0| 6f 65 66 66 73 5b 34 5d | 20 3d 20 2d 62 6c 6f 62 |oeffs[4]| = -blob|
|00002be0| 2d 3e 74 68 72 65 73 68 | 6f 6c 64 3b 0d 0d 20 20 |->thresh|old;.. |
|00002bf0| 2f 2a 20 53 74 65 70 20 | 74 68 72 6f 75 67 68 20 |/* Step |through |
|00002c00| 74 68 65 20 6c 69 73 74 | 20 6f 66 20 69 6e 66 6c |the list| of infl|
|00002c10| 75 65 6e 63 65 20 70 6f | 69 6e 74 73 2c 20 61 64 |uence po|ints, ad|
|00002c20| 64 69 6e 67 20 74 68 65 | 0d 20 20 20 20 20 20 69 |ding the|. i|
|00002c30| 6e 66 6c 75 65 6e 63 65 | 20 6f 66 20 65 61 63 68 |nfluence| of each|
|00002c40| 20 62 6c 6f 62 20 63 6f | 6d 70 6f 6e 65 6e 74 20 | blob co|mponent |
|00002c50| 61 73 20 69 74 20 61 70 | 70 65 61 72 73 20 2a 2f |as it ap|pears */|
|00002c60| 0d 20 20 66 6f 72 20 28 | 69 3d 30 2c 69 6e 5f 66 |. for (|i=0,in_f|
|00002c70| 6c 61 67 3d 30 3b 69 3c | 63 6e 74 3b 69 2b 2b 29 |lag=0;i<|cnt;i++)|
|00002c80| 20 0d 20 20 20 20 7b 0d | 20 20 20 20 69 66 20 28 | . {.| if (|
|00002c90| 69 6e 74 65 72 76 61 6c | 73 5b 69 5d 2e 74 79 70 |interval|s[i].typ|
|00002ca0| 65 20 3d 3d 20 30 29 20 | 0d 20 20 20 20 20 20 7b |e == 0) |. {|
|00002cb0| 0d 20 20 20 20 20 20 2f | 2a 20 53 6f 6d 65 74 68 |. /|* Someth|
|00002cc0| 69 6e 67 20 69 73 20 6a | 75 73 74 20 73 74 61 72 |ing is j|ust star|
|00002cd0| 74 69 6e 67 20 74 6f 20 | 69 6e 66 6c 75 65 6e 63 |ting to |influenc|
|00002ce0| 65 20 74 68 65 20 72 61 | 79 2c 0d 20 20 20 20 20 |e the ra|y,. |
|00002cf0| 20 20 20 20 20 20 20 73 | 6f 20 63 61 6c 63 75 6c | s|o calcul|
|00002d00| 61 74 65 20 69 74 73 20 | 63 6f 65 66 66 69 63 69 |ate its |coeffici|
|00002d10| 65 6e 74 73 20 61 6e 64 | 20 61 64 64 20 74 68 65 |ents and| add the|
|00002d20| 6d 0d 20 20 20 20 20 20 | 20 20 20 69 6e 74 6f 20 |m. | into |
|00002d30| 74 68 65 20 70 6f 74 2e | 20 2a 2f 0d 20 20 20 20 |the pot.| */. |
|00002d40| 20 20 69 6e 5f 66 6c 61 | 67 2b 2b 3b 0d 20 20 20 | in_fla|g++;. |
|00002d50| 20 20 20 65 6c 65 6d 65 | 6e 74 20 3d 20 62 6c 6f | eleme|nt = blo|
|00002d60| 62 2d 3e 6c 69 73 74 5b | 69 6e 74 65 72 76 61 6c |b->list[|interval|
|00002d70| 73 5b 69 5d 2e 69 6e 64 | 65 78 5d 3b 0d 0d 20 20 |s[i].ind|ex];.. |
|00002d80| 20 20 20 20 56 53 75 62 | 28 56 2c 20 50 2c 20 65 | VSub|(V, P, e|
|00002d90| 6c 65 6d 65 6e 74 2d 3e | 70 6f 73 29 3b 0d 20 20 |lement->|pos);. |
|00002da0| 20 20 20 20 63 30 20 3d | 20 65 6c 65 6d 65 6e 74 | c0 =| element|
|00002db0| 2d 3e 63 6f 65 66 66 73 | 5b 30 5d 3b 0d 20 20 20 |->coeffs|[0];. |
|00002dc0| 20 20 20 63 31 20 3d 20 | 65 6c 65 6d 65 6e 74 2d | c1 = |element-|
|00002dd0| 3e 63 6f 65 66 66 73 5b | 31 5d 3b 0d 20 20 20 20 |>coeffs[|1];. |
|00002de0| 20 20 63 32 20 3d 20 65 | 6c 65 6d 65 6e 74 2d 3e | c2 = e|lement->|
|00002df0| 63 6f 65 66 66 73 5b 32 | 5d 3b 0d 20 20 20 20 20 |coeffs[2|];. |
|00002e00| 20 56 44 6f 74 28 74 30 | 2c 20 56 2c 20 56 29 3b | VDot(t0|, V, V);|
|00002e10| 0d 20 20 20 20 20 20 56 | 44 6f 74 28 74 31 2c 20 |. V|Dot(t1, |
|00002e20| 56 2c 20 44 29 3b 0d 20 | 20 20 20 20 20 74 63 6f |V, D);. | tco|
|00002e30| 65 66 66 73 20 3d 20 26 | 28 65 6c 65 6d 65 6e 74 |effs = &|(element|
|00002e40| 2d 3e 74 63 6f 65 66 66 | 73 5b 30 5d 29 3b 0d 0d |->tcoeff|s[0]);..|
|00002e50| 20 20 20 20 20 20 74 63 | 6f 65 66 66 73 5b 30 5d | tc|oeffs[0]|
|00002e60| 20 3d 20 63 30 3b 0d 20 | 20 20 20 20 20 74 63 6f | = c0;. | tco|
|00002e70| 65 66 66 73 5b 31 5d 20 | 3d 20 34 2e 30 20 2a 20 |effs[1] |= 4.0 * |
|00002e80| 63 30 20 2a 20 74 31 3b | 0d 20 20 20 20 20 20 74 |c0 * t1;|. t|
|00002e90| 63 6f 65 66 66 73 5b 32 | 5d 20 3d 20 32 2e 30 20 |coeffs[2|] = 2.0 |
|00002ea0| 2a 20 63 30 20 2a 20 28 | 32 2e 30 20 2a 20 74 31 |* c0 * (|2.0 * t1|
|00002eb0| 20 2a 20 74 31 20 2b 20 | 74 30 29 20 2b 20 63 31 | * t1 + |t0) + c1|
|00002ec0| 3b 0d 20 20 20 20 20 20 | 74 63 6f 65 66 66 73 5b |;. |tcoeffs[|
|00002ed0| 33 5d 20 3d 20 32 2e 30 | 20 2a 20 74 31 20 2a 20 |3] = 2.0| * t1 * |
|00002ee0| 28 32 2e 30 20 2a 20 63 | 30 20 2a 20 74 30 20 2b |(2.0 * c|0 * t0 +|
|00002ef0| 20 63 31 29 3b 0d 20 20 | 20 20 20 20 74 63 6f 65 | c1);. | tcoe|
|00002f00| 66 66 73 5b 34 5d 20 3d | 20 63 30 20 2a 20 74 30 |ffs[4] =| c0 * t0|
|00002f10| 20 2a 20 74 30 20 2b 20 | 63 31 20 2a 20 74 30 20 | * t0 + |c1 * t0 |
|00002f20| 2b 20 63 32 3b 0d 0d 20 | 20 20 20 20 20 66 6f 72 |+ c2;.. | for|
|00002f30| 20 28 6a 3d 30 3b 6a 3c | 35 3b 6a 2b 2b 29 20 63 | (j=0;j<|5;j++) c|
|00002f40| 6f 65 66 66 73 5b 6a 5d | 20 2b 3d 20 74 63 6f 65 |oeffs[j]| += tcoe|
|00002f50| 66 66 73 5b 6a 5d 3b 0d | 20 20 20 20 20 20 7d 0d |ffs[j];.| }.|
|00002f60| 20 20 20 20 65 6c 73 65 | 20 0d 20 20 20 20 20 20 | else| . |
|00002f70| 7b 0d 20 20 20 20 20 20 | 2f 2a 20 57 65 20 61 72 |{. |/* We ar|
|00002f80| 65 20 6c 6f 73 69 6e 67 | 20 74 68 65 20 69 6e 66 |e losing| the inf|
|00002f90| 6c 75 65 6e 63 65 20 6f | 66 20 61 20 63 6f 6d 70 |luence o|f a comp|
|00002fa0| 6f 6e 65 6e 74 2c 20 73 | 6f 0d 20 20 20 20 20 20 |onent, s|o. |
|00002fb0| 20 20 20 20 20 20 73 75 | 62 74 72 61 63 74 20 6f | su|btract o|
|00002fc0| 66 66 20 69 74 73 20 63 | 6f 65 66 66 69 63 69 65 |ff its c|oefficie|
|00002fd0| 6e 74 73 20 2a 2f 0d 20 | 20 20 20 20 20 74 63 6f |nts */. | tco|
|00002fe0| 65 66 66 73 20 3d 20 26 | 28 62 6c 6f 62 2d 3e 6c |effs = &|(blob->l|
|00002ff0| 69 73 74 5b 69 6e 74 65 | 72 76 61 6c 73 5b 69 5d |ist[inte|rvals[i]|
|00003000| 2e 69 6e 64 65 78 5d 2d | 3e 74 63 6f 65 66 66 73 |.index]-|>tcoeffs|
|00003010| 5b 30 5d 29 3b 0d 20 20 | 20 20 20 20 66 6f 72 20 |[0]);. | for |
|00003020| 28 6a 3d 30 3b 6a 3c 35 | 3b 6a 2b 2b 29 20 63 6f |(j=0;j<5|;j++) co|
|00003030| 65 66 66 73 5b 6a 5d 20 | 2d 3d 20 74 63 6f 65 66 |effs[j] |-= tcoef|
|00003040| 66 73 5b 6a 5d 3b 0d 20 | 20 20 20 20 20 69 66 20 |fs[j];. | if |
|00003050| 28 2d 2d 69 6e 5f 66 6c | 61 67 20 3d 3d 20 30 29 |(--in_fl|ag == 0)|
|00003060| 0d 20 20 20 20 20 20 20 | 20 2f 2a 20 4e 6f 6e 65 |. | /* None|
|00003070| 20 6f 66 20 74 68 65 20 | 63 6f 6d 70 6f 6e 65 6e | of the |componen|
|00003080| 74 73 20 61 72 65 20 63 | 75 72 72 65 6e 74 6c 79 |ts are c|urrently|
|00003090| 20 61 66 66 65 63 74 69 | 6e 67 0d 20 20 20 20 20 | affecti|ng. |
|000030a0| 20 20 20 20 20 20 20 20 | 20 20 74 68 65 20 72 61 | | the ra|
|000030b0| 79 20 2d 20 73 6b 69 70 | 20 61 68 65 61 64 2e 20 |y - skip| ahead. |
|000030c0| 2a 2f 0d 20 20 20 20 20 | 20 20 20 63 6f 6e 74 69 |*/. | conti|
|000030d0| 6e 75 65 3b 0d 20 20 20 | 20 20 20 7d 0d 0d 20 20 |nue;. | }.. |
|000030e0| 20 20 2f 2a 20 46 69 67 | 75 72 65 20 6f 75 74 20 | /* Fig|ure out |
|000030f0| 77 68 69 63 68 20 72 6f | 6f 74 20 73 6f 6c 76 65 |which ro|ot solve|
|00003100| 72 20 74 6f 20 75 73 65 | 20 2a 2f 0d 20 20 20 20 |r to use| */. |
|00003110| 69 66 20 28 62 6c 6f 62 | 2d 3e 53 74 75 72 6d 5f |if (blob|->Sturm_|
|00003120| 46 6c 61 67 20 3d 3d 20 | 30 29 0d 20 20 20 20 20 |Flag == |0). |
|00003130| 20 2f 2a 20 55 73 65 20 | 46 65 72 72 61 72 69 27 | /* Use |Ferrari'|
|00003140| 73 20 6d 65 74 68 6f 64 | 20 2a 2f 0d 20 20 20 20 |s method| */. |
|00003150| 20 20 72 6f 6f 74 5f 63 | 6f 75 6e 74 20 3d 20 73 | root_c|ount = s|
|00003160| 6f 6c 76 65 5f 71 75 61 | 72 74 69 63 28 63 6f 65 |olve_qua|rtic(coe|
|00003170| 66 66 73 2c 20 26 72 6f | 6f 74 73 5b 30 5d 29 3b |ffs, &ro|ots[0]);|
|00003180| 0d 20 20 20 20 65 6c 73 | 65 0d 20 20 20 20 20 20 |. els|e. |
|00003190| 2f 2a 20 53 74 75 72 6d | 20 73 65 71 75 65 6e 63 |/* Sturm| sequenc|
|000031a0| 65 73 20 2a 2f 0d 20 20 | 20 20 20 20 69 66 20 28 |es */. | if (|
|000031b0| 66 61 62 73 28 63 6f 65 | 66 66 73 5b 30 5d 29 20 |fabs(coe|ffs[0]) |
|000031c0| 3c 20 43 4f 45 46 46 5f | 4c 49 4d 49 54 29 0d 20 |< COEFF_|LIMIT). |
|000031d0| 20 20 20 20 20 20 20 69 | 66 20 28 66 61 62 73 28 | i|f (fabs(|
|000031e0| 63 6f 65 66 66 73 5b 31 | 5d 29 20 3c 20 43 4f 45 |coeffs[1|]) < COE|
|000031f0| 46 46 5f 4c 49 4d 49 54 | 29 0d 20 20 20 20 20 20 |FF_LIMIT|). |
|00003200| 20 20 20 20 72 6f 6f 74 | 5f 63 6f 75 6e 74 20 3d | root|_count =|
|00003210| 20 73 6f 6c 76 65 5f 71 | 75 61 64 72 61 74 69 63 | solve_q|uadratic|
|00003220| 28 26 63 6f 65 66 66 73 | 5b 32 5d 2c 20 26 72 6f |(&coeffs|[2], &ro|
|00003230| 6f 74 73 5b 30 5d 29 3b | 0d 20 20 20 20 20 20 20 |ots[0]);|. |
|00003240| 20 65 6c 73 65 0d 20 20 | 20 20 20 20 20 20 20 20 | else. | |
|00003250| 72 6f 6f 74 5f 63 6f 75 | 6e 74 20 3d 20 70 6f 6c |root_cou|nt = pol|
|00003260| 79 73 6f 6c 76 65 28 33 | 2c 20 26 63 6f 65 66 66 |ysolve(3|, &coeff|
|00003270| 73 5b 31 5d 2c 20 26 72 | 6f 6f 74 73 5b 30 5d 29 |s[1], &r|oots[0])|
|00003280| 3b 0d 20 20 20 20 20 20 | 65 6c 73 65 0d 20 20 20 |;. |else. |
|00003290| 20 20 20 20 20 72 6f 6f | 74 5f 63 6f 75 6e 74 20 | roo|t_count |
|000032a0| 3d 20 70 6f 6c 79 73 6f | 6c 76 65 28 34 2c 20 63 |= polyso|lve(4, c|
|000032b0| 6f 65 66 66 73 2c 20 26 | 72 6f 6f 74 73 5b 30 5d |oeffs, &|roots[0]|
|000032c0| 29 3b 0d 0d 20 20 20 20 | 2f 2a 20 53 65 65 20 69 |);.. |/* See i|
|000032d0| 66 20 61 6e 79 20 6f 66 | 20 74 68 65 20 72 6f 6f |f any of| the roo|
|000032e0| 74 73 20 61 72 65 20 76 | 61 6c 69 64 20 2a 2f 0d |ts are v|alid */.|
|000032f0| 20 20 20 20 66 6f 72 28 | 6a 3d 30 3b 6a 3c 72 6f | for(|j=0;j<ro|
|00003300| 6f 74 5f 63 6f 75 6e 74 | 3b 6a 2b 2b 29 20 0d 20 |ot_count|;j++) . |
|00003310| 20 20 20 20 20 7b 0d 20 | 20 20 20 20 20 64 69 73 | {. | dis|
|00003320| 74 20 3d 20 72 6f 6f 74 | 73 5b 6a 5d 3b 0d 20 20 |t = root|s[j];. |
|00003330| 20 20 20 20 2f 2a 20 46 | 69 72 73 74 20 73 65 65 | /* F|irst see|
|00003340| 20 69 66 20 74 68 65 20 | 72 6f 6f 74 20 69 73 20 | if the |root is |
|00003350| 69 6e 20 74 68 65 20 69 | 6e 74 65 72 76 61 6c 20 |in the i|nterval |
|00003360| 6f 66 20 69 6e 66 6c 75 | 65 6e 63 65 20 6f 66 0d |of influ|ence of.|
|00003370| 20 20 20 20 20 20 20 20 | 20 20 20 20 74 68 65 20 | | the |
|00003380| 63 75 72 72 65 6e 74 6c | 79 20 61 63 74 69 76 65 |currentl|y active|
|00003390| 20 63 6f 6d 70 6f 6e 65 | 6e 74 73 20 6f 66 20 74 | compone|nts of t|
|000033a0| 68 65 20 62 6c 6f 62 20 | 2a 2f 0d 20 20 20 20 20 |he blob |*/. |
|000033b0| 20 69 66 20 28 28 64 69 | 73 74 20 3e 3d 20 69 6e | if ((di|st >= in|
|000033c0| 74 65 72 76 61 6c 73 5b | 69 5d 2e 62 6f 75 6e 64 |tervals[|i].bound|
|000033d0| 29 20 26 26 0d 20 20 20 | 20 20 20 20 20 28 64 69 |) &&. | (di|
|000033e0| 73 74 20 3c 3d 20 69 6e | 74 65 72 76 61 6c 73 5b |st <= in|tervals[|
|000033f0| 69 2b 31 5d 2e 62 6f 75 | 6e 64 29 20 26 26 0d 20 |i+1].bou|nd) &&. |
|00003400| 20 20 20 20 20 20 20 28 | 64 69 73 74 20 3e 20 42 | (|dist > B|
|00003410| 6c 6f 62 5f 54 6f 6c 65 | 72 61 6e 63 65 29 29 20 |lob_Tole|rance)) |
|00003420| 0d 20 20 20 20 20 20 20 | 20 7b 0d 20 20 20 20 20 |. | {. |
|00003430| 20 20 20 56 53 63 61 6c | 65 28 49 50 6f 69 6e 74 | VScal|e(IPoint|
|00003440| 2c 20 44 2c 20 64 69 73 | 74 29 3b 0d 20 20 20 20 |, D, dis|t);. |
|00003450| 20 20 20 20 56 41 64 64 | 28 49 50 6f 69 6e 74 2c | VAdd|(IPoint,|
|00003460| 20 49 50 6f 69 6e 74 2c | 20 50 29 3b 0d 20 20 20 | IPoint,| P);. |
|00003470| 20 20 20 20 20 2f 2a 20 | 54 72 61 6e 73 66 6f 72 | /* |Transfor|
|00003480| 6d 20 74 68 65 20 70 6f | 69 6e 74 20 69 6e 74 6f |m the po|int into|
|00003490| 20 77 6f 72 6c 64 20 73 | 70 61 63 65 20 2a 2f 0d | world s|pace */.|
|000034a0| 20 20 20 20 20 20 20 20 | 69 66 20 28 62 6c 6f 62 | |if (blob|
|000034b0| 2d 3e 54 72 61 6e 73 20 | 21 3d 20 4e 55 4c 4c 29 |->Trans |!= NULL)|
|000034c0| 0d 20 20 20 20 20 20 20 | 20 20 20 4d 54 72 61 6e |. | MTran|
|000034d0| 73 50 6f 69 6e 74 28 26 | 49 50 6f 69 6e 74 2c 20 |sPoint(&|IPoint, |
|000034e0| 26 49 50 6f 69 6e 74 2c | 20 62 6c 6f 62 2d 3e 54 |&IPoint,| blob->T|
|000034f0| 72 61 6e 73 29 3b 0d 20 | 20 20 20 20 20 20 20 56 |rans);. | V|
|00003500| 53 75 62 28 64 76 2c 20 | 49 50 6f 69 6e 74 2c 20 |Sub(dv, |IPoint, |
|00003510| 52 61 79 2d 3e 49 6e 69 | 74 69 61 6c 29 3b 0d 20 |Ray->Ini|tial);. |
|00003520| 20 20 20 20 20 20 20 56 | 4c 65 6e 67 74 68 28 6c | V|Length(l|
|00003530| 65 6e 2c 20 64 76 29 3b | 0d 20 20 20 20 20 20 20 |en, dv);|. |
|00003540| 20 69 66 20 28 50 6f 69 | 6e 74 5f 49 6e 5f 43 6c | if (Poi|nt_In_Cl|
|00003550| 69 70 28 26 49 50 6f 69 | 6e 74 2c 20 4f 62 6a 65 |ip(&IPoi|nt, Obje|
|00003560| 63 74 2d 3e 43 6c 69 70 | 29 29 20 0d 20 20 20 20 |ct->Clip|)) . |
|00003570| 20 20 20 20 20 20 7b 0d | 20 20 20 20 20 20 20 20 | {.| |
|00003580| 20 20 70 75 73 68 5f 65 | 6e 74 72 79 28 6c 65 6e | push_e|ntry(len|
|00003590| 2c 49 50 6f 69 6e 74 2c | 4f 62 6a 65 63 74 2c 44 |,IPoint,|Object,D|
|000035a0| 65 70 74 68 5f 53 74 61 | 63 6b 29 3b 0d 20 20 20 |epth_Sta|ck);. |
|000035b0| 20 20 20 20 20 20 20 49 | 6e 74 65 72 73 65 63 74 | I|ntersect|
|000035c0| 69 6f 6e 5f 46 6f 75 6e | 64 20 3d 20 54 52 55 45 |ion_Foun|d = TRUE|
|000035d0| 3b 0d 20 20 20 20 20 20 | 20 20 20 20 7d 0d 20 20 |;. | }. |
|000035e0| 20 20 20 20 20 20 7d 0d | 20 20 20 20 20 20 7d 0d | }.| }.|
|000035f0| 20 20 20 20 7d 0d 20 20 | 69 66 28 49 6e 74 65 72 | }. |if(Inter|
|00003600| 73 65 63 74 69 6f 6e 5f | 46 6f 75 6e 64 29 0d 20 |section_|Found). |
|00003610| 20 20 20 52 61 79 5f 42 | 6c 6f 62 5f 54 65 73 74 | Ray_B|lob_Test|
|00003620| 73 5f 53 75 63 63 65 65 | 64 65 64 2b 2b 3b 0d 20 |s_Succee|ded++;. |
|00003630| 20 72 65 74 75 72 6e 20 | 49 6e 74 65 72 73 65 63 | return |Intersec|
|00003640| 74 69 6f 6e 5f 46 6f 75 | 6e 64 3b 0d 20 20 7d 0d |tion_Fou|nd;. }.|
|00003650| 0d 2f 2a 20 43 61 6c 63 | 75 6c 61 74 65 20 74 68 |./* Calc|ulate th|
|00003660| 65 20 64 65 6e 73 69 74 | 79 20 61 74 20 74 68 69 |e densit|y at thi|
|00003670| 73 20 70 6f 69 6e 74 2c | 20 74 68 65 6e 20 63 6f |s point,| then co|
|00003680| 6d 70 61 72 65 20 74 6f | 0d 20 20 20 74 68 65 20 |mpare to|. the |
|00003690| 74 68 72 65 73 68 6f 6c | 64 20 74 6f 20 73 65 65 |threshol|d to see|
|000036a0| 20 69 66 20 77 65 20 61 | 72 65 20 69 6e 20 6f 72 | if we a|re in or|
|000036b0| 20 6f 75 74 20 6f 66 20 | 74 68 65 20 62 6c 6f 62 | out of |the blob|
|000036c0| 20 2a 2f 0d 69 6e 74 20 | 49 6e 73 69 64 65 5f 42 | */.int |Inside_B|
|000036d0| 6c 6f 62 20 28 54 65 73 | 74 5f 50 6f 69 6e 74 2c |lob (Tes|t_Point,|
|000036e0| 20 4f 62 6a 65 63 74 29 | 0d 56 45 43 54 4f 52 20 | Object)|.VECTOR |
|000036f0| 2a 54 65 73 74 5f 50 6f | 69 6e 74 3b 0d 4f 42 4a |*Test_Po|int;.OBJ|
|00003700| 45 43 54 20 2a 4f 62 6a | 65 63 74 3b 0d 20 20 7b |ECT *Obj|ect;. {|
|00003710| 0d 20 20 56 45 43 54 4f | 52 20 4e 65 77 5f 50 6f |. VECTO|R New_Po|
|00003720| 69 6e 74 3b 0d 20 20 42 | 4c 4f 42 20 2a 62 6c 6f |int;. B|LOB *blo|
|00003730| 62 20 3d 20 28 42 4c 4f | 42 20 2a 29 20 4f 62 6a |b = (BLO|B *) Obj|
|00003740| 65 63 74 3b 0d 0d 20 20 | 2f 2a 20 54 72 61 6e 73 |ect;.. |/* Trans|
|00003750| 66 6f 72 6d 20 74 68 65 | 20 70 6f 69 6e 74 20 69 |form the| point i|
|00003760| 6e 74 6f 20 62 6c 6f 62 | 20 73 70 61 63 65 20 2a |nto blob| space *|
|00003770| 2f 0d 20 20 69 66 20 28 | 62 6c 6f 62 2d 3e 54 72 |/. if (|blob->Tr|
|00003780| 61 6e 73 20 21 3d 20 4e | 55 4c 4c 29 0d 20 20 20 |ans != N|ULL). |
|00003790| 20 4d 49 6e 76 54 72 61 | 6e 73 50 6f 69 6e 74 28 | MInvTra|nsPoint(|
|000037a0| 26 4e 65 77 5f 50 6f 69 | 6e 74 2c 20 54 65 73 74 |&New_Poi|nt, Test|
|000037b0| 5f 50 6f 69 6e 74 2c 20 | 62 6c 6f 62 2d 3e 54 72 |_Point, |blob->Tr|
|000037c0| 61 6e 73 29 3b 0d 20 20 | 65 6c 73 65 0d 20 20 20 |ans);. |else. |
|000037d0| 20 4e 65 77 5f 50 6f 69 | 6e 74 20 3d 20 2a 54 65 | New_Poi|nt = *Te|
|000037e0| 73 74 5f 50 6f 69 6e 74 | 3b 0d 0d 20 20 69 66 20 |st_Point|;.. if |
|000037f0| 28 63 61 6c 63 75 6c 61 | 74 65 5f 66 69 65 6c 64 |(calcula|te_field|
|00003800| 5f 76 61 6c 75 65 28 4f | 62 6a 65 63 74 2c 20 26 |_value(O|bject, &|
|00003810| 4e 65 77 5f 50 6f 69 6e | 74 29 20 3e 0d 20 20 20 |New_Poin|t) >. |
|00003820| 20 62 6c 6f 62 2d 3e 74 | 68 72 65 73 68 6f 6c 64 | blob->t|hreshold|
|00003830| 2d 49 4e 53 49 44 45 5f | 54 4f 4c 45 52 41 4e 43 |-INSIDE_|TOLERANC|
|00003840| 45 29 0d 20 20 20 20 72 | 65 74 75 72 6e 20 28 28 |E). r|eturn ((|
|00003850| 69 6e 74 29 20 31 2d 62 | 6c 6f 62 2d 3e 49 6e 76 |int) 1-b|lob->Inv|
|00003860| 65 72 74 65 64 29 3b 0d | 20 20 65 6c 73 65 0d 20 |erted);.| else. |
|00003870| 20 20 20 72 65 74 75 72 | 6e 20 28 28 69 6e 74 29 | retur|n ((int)|
|00003880| 20 62 6c 6f 62 2d 3e 49 | 6e 76 65 72 74 65 64 29 | blob->I|nverted)|
|00003890| 3b 0d 20 20 7d 0d 0d 76 | 6f 69 64 20 42 6c 6f 62 |;. }..v|oid Blob|
|000038a0| 5f 4e 6f 72 6d 61 6c 20 | 28 52 65 73 75 6c 74 2c |_Normal |(Result,|
|000038b0| 20 4f 62 6a 65 63 74 2c | 20 49 50 6f 69 6e 74 29 | Object,| IPoint)|
|000038c0| 0d 4f 42 4a 45 43 54 20 | 2a 4f 62 6a 65 63 74 3b |.OBJECT |*Object;|
|000038d0| 0d 56 45 43 54 4f 52 20 | 2a 52 65 73 75 6c 74 2c |.VECTOR |*Result,|
|000038e0| 20 2a 49 50 6f 69 6e 74 | 3b 0d 20 20 7b 0d 20 20 | *IPoint|;. {. |
|000038f0| 56 45 43 54 4f 52 20 4e | 65 77 5f 50 6f 69 6e 74 |VECTOR N|ew_Point|
|00003900| 2c 20 56 3b 0d 20 20 69 | 6e 74 20 69 3b 0d 20 20 |, V;. i|nt i;. |
|00003910| 44 42 4c 20 64 69 73 74 | 2c 20 76 61 6c 3b 0d 20 |DBL dist|, val;. |
|00003920| 20 42 4c 4f 42 20 2a 62 | 6c 6f 62 20 3d 20 28 42 | BLOB *b|lob = (B|
|00003930| 4c 4f 42 20 2a 29 20 4f | 62 6a 65 63 74 3b 0d 20 |LOB *) O|bject;. |
|00003940| 20 42 6c 6f 62 5f 45 6c | 65 6d 65 6e 74 20 2a 74 | Blob_El|ement *t|
|00003950| 65 6d 70 3b 0d 0d 20 20 | 2f 2a 20 54 72 61 6e 73 |emp;.. |/* Trans|
|00003960| 66 6f 72 6d 20 74 68 65 | 20 70 6f 69 6e 74 20 69 |form the| point i|
|00003970| 6e 74 6f 20 74 68 65 20 | 62 6c 6f 62 73 20 73 70 |nto the |blobs sp|
|00003980| 61 63 65 20 2a 2f 0d 20 | 20 69 66 20 28 62 6c 6f |ace */. | if (blo|
|00003990| 62 2d 3e 54 72 61 6e 73 | 20 21 3d 20 4e 55 4c 4c |b->Trans| != NULL|
|000039a0| 29 0d 20 20 20 20 4d 49 | 6e 76 54 72 61 6e 73 50 |). MI|nvTransP|
|000039b0| 6f 69 6e 74 28 26 4e 65 | 77 5f 50 6f 69 6e 74 2c |oint(&Ne|w_Point,|
|000039c0| 20 49 50 6f 69 6e 74 2c | 20 62 6c 6f 62 2d 3e 54 | IPoint,| blob->T|
|000039d0| 72 61 6e 73 29 3b 0d 20 | 20 65 6c 73 65 0d 20 20 |rans);. | else. |
|000039e0| 20 20 4e 65 77 5f 50 6f | 69 6e 74 20 3d 20 2a 49 | New_Po|int = *I|
|000039f0| 50 6f 69 6e 74 3b 0d 0d | 20 20 4d 61 6b 65 5f 56 |Point;..| Make_V|
|00003a00| 65 63 74 6f 72 28 52 65 | 73 75 6c 74 2c 20 30 2c |ector(Re|sult, 0,|
|00003a10| 20 30 2c 20 30 29 3b 0d | 0d 20 20 2f 2a 20 46 6f | 0, 0);.|. /* Fo|
|00003a20| 72 20 65 61 63 68 20 63 | 6f 6d 70 6f 6e 65 6e 74 |r each c|omponent|
|00003a30| 20 74 68 61 74 20 63 6f | 6e 74 72 69 62 75 74 65 | that co|ntribute|
|00003a40| 73 20 74 6f 20 74 68 69 | 73 20 70 6f 69 6e 74 2c |s to thi|s point,|
|00003a50| 20 61 64 64 0d 20 20 20 | 20 20 20 69 74 73 20 62 | add. | its b|
|00003a60| 69 74 20 74 6f 20 74 68 | 65 20 6e 6f 72 6d 61 6c |it to th|e normal|
|00003a70| 20 2a 2f 0d 20 20 66 6f | 72 28 69 3d 30 3b 69 3c | */. fo|r(i=0;i<|
|00003a80| 62 6c 6f 62 2d 3e 63 6f | 75 6e 74 3b 69 2b 2b 29 |blob->co|unt;i++)|
|00003a90| 20 0d 20 20 20 20 7b 0d | 20 20 20 20 74 65 6d 70 | . {.| temp|
|00003aa0| 20 3d 20 62 6c 6f 62 2d | 3e 6c 69 73 74 5b 69 5d | = blob-|>list[i]|
|00003ab0| 3b 0d 20 20 20 20 56 2e | 78 20 3d 20 4e 65 77 5f |;. V.|x = New_|
|00003ac0| 50 6f 69 6e 74 2e 78 20 | 2d 20 74 65 6d 70 2d 3e |Point.x |- temp->|
|00003ad0| 70 6f 73 2e 78 3b 0d 20 | 20 20 20 56 2e 79 20 3d |pos.x;. | V.y =|
|00003ae0| 20 4e 65 77 5f 50 6f 69 | 6e 74 2e 79 20 2d 20 74 | New_Poi|nt.y - t|
|00003af0| 65 6d 70 2d 3e 70 6f 73 | 2e 79 3b 0d 20 20 20 20 |emp->pos|.y;. |
|00003b00| 56 2e 7a 20 3d 20 4e 65 | 77 5f 50 6f 69 6e 74 2e |V.z = Ne|w_Point.|
|00003b10| 7a 20 2d 20 74 65 6d 70 | 2d 3e 70 6f 73 2e 7a 3b |z - temp|->pos.z;|
|00003b20| 0d 20 20 20 20 64 69 73 | 74 20 3d 20 28 56 2e 78 |. dis|t = (V.x|
|00003b30| 20 2a 20 56 2e 78 20 2b | 20 56 2e 79 20 2a 20 56 | * V.x +| V.y * V|
|00003b40| 2e 79 20 2b 20 56 2e 7a | 20 2a 20 56 2e 7a 29 3b |.y + V.z| * V.z);|
|00003b50| 0d 0d 20 20 20 20 69 66 | 20 28 64 69 73 74 20 3c |.. if| (dist <|
|00003b60| 3d 20 74 65 6d 70 2d 3e | 72 61 64 69 75 73 32 29 |= temp->|radius2)|
|00003b70| 20 0d 20 20 20 20 20 20 | 7b 0d 20 20 20 20 20 20 | . |{. |
|00003b80| 76 61 6c 20 3d 20 2d 32 | 2e 30 20 2a 20 28 32 2e |val = -2|.0 * (2.|
|00003b90| 30 20 2a 20 74 65 6d 70 | 2d 3e 63 6f 65 66 66 73 |0 * temp|->coeffs|
|00003ba0| 5b 30 5d 20 2a 20 64 69 | 73 74 20 2b 0d 20 20 20 |[0] * di|st +. |
|00003bb0| 20 20 20 20 20 74 65 6d | 70 2d 3e 63 6f 65 66 66 | tem|p->coeff|
|00003bc0| 73 5b 31 5d 29 3b 0d 20 | 20 20 20 20 20 52 65 73 |s[1]);. | Res|
|00003bd0| 75 6c 74 2d 3e 78 20 2b | 3d 20 76 61 6c 20 2a 20 |ult->x +|= val * |
|00003be0| 56 2e 78 3b 0d 20 20 20 | 20 20 20 52 65 73 75 6c |V.x;. | Resul|
|00003bf0| 74 2d 3e 79 20 2b 3d 20 | 76 61 6c 20 2a 20 56 2e |t->y += |val * V.|
|00003c00| 79 3b 0d 20 20 20 20 20 | 20 52 65 73 75 6c 74 2d |y;. | Result-|
|00003c10| 3e 7a 20 2b 3d 20 76 61 | 6c 20 2a 20 56 2e 7a 3b |>z += va|l * V.z;|
|00003c20| 0d 20 20 20 20 20 20 7d | 0d 20 20 20 20 7d 0d 20 |. }|. }. |
|00003c30| 20 76 61 6c 20 3d 20 28 | 52 65 73 75 6c 74 2d 3e | val = (|Result->|
|00003c40| 78 20 2a 20 52 65 73 75 | 6c 74 2d 3e 78 20 2b 20 |x * Resu|lt->x + |
|00003c50| 52 65 73 75 6c 74 2d 3e | 79 20 2a 20 52 65 73 75 |Result->|y * Resu|
|00003c60| 6c 74 2d 3e 79 20 2b 0d | 20 20 20 20 52 65 73 75 |lt->y +.| Resu|
|00003c70| 6c 74 2d 3e 7a 20 2a 20 | 52 65 73 75 6c 74 2d 3e |lt->z * |Result->|
|00003c80| 7a 29 3b 0d 20 20 69 66 | 20 28 76 61 6c 20 3c 20 |z);. if| (val < |
|00003c90| 45 50 53 49 4c 4f 4e 29 | 20 0d 20 20 20 20 7b 0d |EPSILON)| . {.|
|00003ca0| 20 20 20 20 52 65 73 75 | 6c 74 2d 3e 78 20 3d 20 | Resu|lt->x = |
|00003cb0| 31 2e 30 3b 0d 20 20 20 | 20 52 65 73 75 6c 74 2d |1.0;. | Result-|
|00003cc0| 3e 79 20 3d 20 30 2e 30 | 3b 0d 20 20 20 20 52 65 |>y = 0.0|;. Re|
|00003cd0| 73 75 6c 74 2d 3e 7a 20 | 3d 20 30 2e 30 3b 0d 20 |sult->z |= 0.0;. |
|00003ce0| 20 20 20 7d 0d 20 20 65 | 6c 73 65 20 0d 20 20 20 | }. e|lse . |
|00003cf0| 20 7b 0d 20 20 20 20 76 | 61 6c 20 3d 20 31 2e 30 | {. v|al = 1.0|
|00003d00| 20 2f 20 73 71 72 74 28 | 76 61 6c 29 3b 0d 20 20 | / sqrt(|val);. |
|00003d10| 20 20 52 65 73 75 6c 74 | 2d 3e 78 20 2a 3d 20 76 | Result|->x *= v|
|00003d20| 61 6c 3b 0d 20 20 20 20 | 52 65 73 75 6c 74 2d 3e |al;. |Result->|
|00003d30| 79 20 2a 3d 20 76 61 6c | 3b 0d 20 20 20 20 52 65 |y *= val|;. Re|
|00003d40| 73 75 6c 74 2d 3e 7a 20 | 2a 3d 20 76 61 6c 3b 0d |sult->z |*= val;.|
|00003d50| 20 20 20 20 7d 0d 0d 20 | 20 20 20 2f 2a 20 54 72 | }.. | /* Tr|
|00003d60| 61 6e 73 66 6f 72 6d 20 | 62 61 63 6b 20 74 6f 20 |ansform |back to |
|00003d70| 77 6f 72 6c 64 20 73 70 | 61 63 65 20 2a 2f 0d 20 |world sp|ace */. |
|00003d80| 20 20 20 69 66 20 28 62 | 6c 6f 62 2d 3e 54 72 61 | if (b|lob->Tra|
|00003d90| 6e 73 20 21 3d 20 4e 55 | 4c 4c 29 0d 20 20 20 20 |ns != NU|LL). |
|00003da0| 20 20 4d 54 72 61 6e 73 | 4e 6f 72 6d 61 6c 28 52 | MTrans|Normal(R|
|00003db0| 65 73 75 6c 74 2c 20 52 | 65 73 75 6c 74 2c 20 62 |esult, R|esult, b|
|00003dc0| 6c 6f 62 2d 3e 54 72 61 | 6e 73 29 3b 0d 20 20 56 |lob->Tra|ns);. V|
|00003dd0| 4e 6f 72 6d 61 6c 69 7a | 65 28 2a 52 65 73 75 6c |Normaliz|e(*Resul|
|00003de0| 74 2c 20 2a 52 65 73 75 | 6c 74 29 3b 0d 20 20 7d |t, *Resu|lt);. }|
|00003df0| 0d 0d 76 6f 69 64 20 54 | 72 61 6e 73 6c 61 74 65 |..void T|ranslate|
|00003e00| 5f 42 6c 6f 62 20 28 4f | 62 6a 65 63 74 2c 20 56 |_Blob (O|bject, V|
|00003e10| 65 63 74 6f 72 29 0d 4f | 42 4a 45 43 54 20 2a 4f |ector).O|BJECT *O|
|00003e20| 62 6a 65 63 74 3b 0d 56 | 45 43 54 4f 52 20 2a 56 |bject;.V|ECTOR *V|
|00003e30| 65 63 74 6f 72 3b 0d 20 | 20 7b 0d 20 20 54 52 41 |ector;. | {. TRA|
|00003e40| 4e 53 46 4f 52 4d 20 54 | 72 61 6e 73 3b 0d 20 20 |NSFORM T|rans;. |
|00003e50| 43 6f 6d 70 75 74 65 5f | 54 72 61 6e 73 6c 61 74 |Compute_|Translat|
|00003e60| 69 6f 6e 5f 54 72 61 6e | 73 66 6f 72 6d 28 26 54 |ion_Tran|sform(&T|
|00003e70| 72 61 6e 73 2c 20 56 65 | 63 74 6f 72 29 3b 0d 20 |rans, Ve|ctor);. |
|00003e80| 20 54 72 61 6e 73 66 6f | 72 6d 5f 42 6c 6f 62 28 | Transfo|rm_Blob(|
|00003e90| 4f 62 6a 65 63 74 2c 20 | 26 54 72 61 6e 73 29 3b |Object, |&Trans);|
|00003ea0| 0d 20 20 7d 0d 0d 76 6f | 69 64 20 52 6f 74 61 74 |. }..vo|id Rotat|
|00003eb0| 65 5f 42 6c 6f 62 20 28 | 4f 62 6a 65 63 74 2c 20 |e_Blob (|Object, |
|00003ec0| 56 65 63 74 6f 72 29 0d | 4f 42 4a 45 43 54 20 2a |Vector).|OBJECT *|
|00003ed0| 4f 62 6a 65 63 74 3b 0d | 56 45 43 54 4f 52 20 2a |Object;.|VECTOR *|
|00003ee0| 56 65 63 74 6f 72 3b 0d | 20 20 7b 0d 20 20 54 52 |Vector;.| {. TR|
|00003ef0| 41 4e 53 46 4f 52 4d 20 | 54 72 61 6e 73 3b 0d 20 |ANSFORM |Trans;. |
|00003f00| 20 43 6f 6d 70 75 74 65 | 5f 52 6f 74 61 74 69 6f | Compute|_Rotatio|
|00003f10| 6e 5f 54 72 61 6e 73 66 | 6f 72 6d 28 26 54 72 61 |n_Transf|orm(&Tra|
|00003f20| 6e 73 2c 20 56 65 63 74 | 6f 72 29 3b 0d 20 20 54 |ns, Vect|or);. T|
|00003f30| 72 61 6e 73 66 6f 72 6d | 5f 42 6c 6f 62 28 4f 62 |ransform|_Blob(Ob|
|00003f40| 6a 65 63 74 2c 20 26 54 | 72 61 6e 73 29 3b 0d 20 |ject, &T|rans);. |
|00003f50| 20 7d 0d 0d 76 6f 69 64 | 20 53 63 61 6c 65 5f 42 | }..void| Scale_B|
|00003f60| 6c 6f 62 20 28 4f 62 6a | 65 63 74 2c 20 56 65 63 |lob (Obj|ect, Vec|
|00003f70| 74 6f 72 29 0d 4f 42 4a | 45 43 54 20 2a 4f 62 6a |tor).OBJ|ECT *Obj|
|00003f80| 65 63 74 3b 0d 56 45 43 | 54 4f 52 20 2a 56 65 63 |ect;.VEC|TOR *Vec|
|00003f90| 74 6f 72 3b 0d 20 20 7b | 0d 20 20 54 52 41 4e 53 |tor;. {|. TRANS|
|00003fa0| 46 4f 52 4d 20 54 72 61 | 6e 73 3b 0d 20 20 43 6f |FORM Tra|ns;. Co|
|00003fb0| 6d 70 75 74 65 5f 53 63 | 61 6c 69 6e 67 5f 54 72 |mpute_Sc|aling_Tr|
|00003fc0| 61 6e 73 66 6f 72 6d 28 | 26 54 72 61 6e 73 2c 20 |ansform(|&Trans, |
|00003fd0| 56 65 63 74 6f 72 29 3b | 0d 20 20 54 72 61 6e 73 |Vector);|. Trans|
|00003fe0| 66 6f 72 6d 5f 42 6c 6f | 62 28 4f 62 6a 65 63 74 |form_Blo|b(Object|
|00003ff0| 2c 20 26 54 72 61 6e 73 | 29 3b 0d 20 20 7d 0d 0d |, &Trans|);. }..|
|00004000| 76 6f 69 64 20 54 72 61 | 6e 73 66 6f 72 6d 5f 42 |void Tra|nsform_B|
|00004010| 6c 6f 62 28 4f 62 6a 65 | 63 74 2c 54 72 61 6e 73 |lob(Obje|ct,Trans|
|00004020| 29 0d 4f 42 4a 45 43 54 | 20 2a 4f 62 6a 65 63 74 |).OBJECT| *Object|
|00004030| 3b 0d 54 52 41 4e 53 46 | 4f 52 4d 20 2a 54 72 61 |;.TRANSF|ORM *Tra|
|00004040| 6e 73 3b 0d 20 20 7b 0d | 20 20 69 66 20 28 28 28 |ns;. {.| if (((|
|00004050| 42 4c 4f 42 20 2a 29 4f | 62 6a 65 63 74 29 2d 3e |BLOB *)O|bject)->|
|00004060| 54 72 61 6e 73 20 3d 3d | 20 4e 55 4c 4c 29 0d 20 |Trans ==| NULL). |
|00004070| 20 20 20 28 28 42 4c 4f | 42 20 2a 29 4f 62 6a 65 | ((BLO|B *)Obje|
|00004080| 63 74 29 2d 3e 54 72 61 | 6e 73 20 3d 20 43 72 65 |ct)->Tra|ns = Cre|
|00004090| 61 74 65 5f 54 72 61 6e | 73 66 6f 72 6d 28 29 3b |ate_Tran|sform();|
|000040a0| 0d 20 20 72 65 63 6f 6d | 70 75 74 65 5f 62 62 6f |. recom|pute_bbo|
|000040b0| 78 28 26 4f 62 6a 65 63 | 74 2d 3e 42 6f 75 6e 64 |x(&Objec|t->Bound|
|000040c0| 73 2c 20 54 72 61 6e 73 | 29 3b 0d 20 20 43 6f 6d |s, Trans|);. Com|
|000040d0| 70 6f 73 65 5f 54 72 61 | 6e 73 66 6f 72 6d 73 28 |pose_Tra|nsforms(|
|000040e0| 28 28 42 4c 4f 42 20 2a | 29 4f 62 6a 65 63 74 29 |((BLOB *|)Object)|
|000040f0| 2d 3e 54 72 61 6e 73 2c | 20 54 72 61 6e 73 29 3b |->Trans,| Trans);|
|00004100| 0d 20 20 7d 0d 0d 76 6f | 69 64 20 49 6e 76 65 72 |. }..vo|id Inver|
|00004110| 74 5f 42 6c 6f 62 28 4f | 62 6a 65 63 74 29 0d 4f |t_Blob(O|bject).O|
|00004120| 42 4a 45 43 54 20 2a 4f | 62 6a 65 63 74 3b 0d 20 |BJECT *O|bject;. |
|00004130| 20 7b 0d 20 20 28 28 42 | 4c 4f 42 20 2a 29 20 4f | {. ((B|LOB *) O|
|00004140| 62 6a 65 63 74 29 2d 3e | 49 6e 76 65 72 74 65 64 |bject)->|Inverted|
|00004150| 20 3d 20 31 20 2d 20 28 | 28 42 4c 4f 42 20 2a 29 | = 1 - (|(BLOB *)|
|00004160| 4f 62 6a 65 63 74 29 2d | 3e 49 6e 76 65 72 74 65 |Object)-|>Inverte|
|00004170| 64 3b 0d 20 20 7d 0d 0d | 76 6f 69 64 20 2a 43 6f |d;. }..|void *Co|
|00004180| 70 79 5f 42 6c 6f 62 20 | 28 4f 62 6a 65 63 74 29 |py_Blob |(Object)|
|00004190| 0d 4f 42 4a 45 43 54 20 | 2a 4f 62 6a 65 63 74 3b |.OBJECT |*Object;|
|000041a0| 0d 20 20 7b 0d 20 20 42 | 4c 4f 42 20 2a 4e 65 77 |. {. B|LOB *New|
|000041b0| 3b 0d 20 20 75 6e 73 69 | 67 6e 65 64 20 69 2c 20 |;. unsi|gned i, |
|000041c0| 63 6e 74 3b 0d 0d 20 20 | 4e 65 77 20 3d 20 43 72 |cnt;.. |New = Cr|
|000041d0| 65 61 74 65 5f 42 6c 6f | 62 28 29 3b 0d 20 20 2a |eate_Blo|b();. *|
|000041e0| 4e 65 77 20 3d 20 2a 20 | 28 28 42 4c 4f 42 20 2a |New = * |((BLOB *|
|000041f0| 29 4f 62 6a 65 63 74 29 | 3b 0d 0d 20 20 4e 65 77 |)Object)|;.. New|
|00004200| 2d 3e 54 72 61 6e 73 20 | 3d 20 43 6f 70 79 5f 54 |->Trans |= Copy_T|
|00004210| 72 61 6e 73 66 6f 72 6d | 28 4e 65 77 2d 3e 54 72 |ransform|(New->Tr|
|00004220| 61 6e 73 29 3b 0d 0d 20 | 20 63 6e 74 20 3d 20 28 |ans);.. | cnt = (|
|00004230| 28 42 4c 4f 42 20 2a 29 | 4f 62 6a 65 63 74 29 2d |(BLOB *)|Object)-|
|00004240| 3e 63 6f 75 6e 74 3b 0d | 20 20 4e 65 77 2d 3e 6c |>count;.| New->l|
|00004250| 69 73 74 20 3d 20 28 42 | 6c 6f 62 5f 45 6c 65 6d |ist = (B|lob_Elem|
|00004260| 65 6e 74 20 2a 2a 29 6d | 61 6c 6c 6f 63 28 63 6e |ent **)m|alloc(cn|
|00004270| 74 20 2a 20 73 69 7a 65 | 6f 66 28 42 6c 6f 62 5f |t * size|of(Blob_|
|00004280| 45 6c 65 6d 65 6e 74 20 | 2a 29 29 3b 0d 20 20 69 |Element |*));. i|
|00004290| 66 20 28 4e 65 77 2d 3e | 6c 69 73 74 20 3d 3d 20 |f (New->|list == |
|000042a0| 4e 55 4c 4c 29 20 0d 20 | 20 20 20 4d 41 45 72 72 |NULL) . | MAErr|
|000042b0| 6f 72 28 22 62 6c 6f 62 | 20 64 61 74 61 22 29 3b |or("blob| data");|
|000042c0| 0d 20 20 66 6f 72 20 28 | 69 3d 30 3b 69 3c 63 6e |. for (|i=0;i<cn|
|000042d0| 74 3b 69 2b 2b 29 20 0d | 20 20 20 20 7b 0d 20 20 |t;i++) .| {. |
|000042e0| 20 20 4e 65 77 2d 3e 6c | 69 73 74 5b 69 5d 20 3d | New->l|ist[i] =|
|000042f0| 20 28 42 6c 6f 62 5f 45 | 6c 65 6d 65 6e 74 20 2a | (Blob_E|lement *|
|00004300| 29 6d 61 6c 6c 6f 63 28 | 73 69 7a 65 6f 66 28 42 |)malloc(|sizeof(B|
|00004310| 6c 6f 62 5f 45 6c 65 6d | 65 6e 74 29 29 3b 0d 20 |lob_Elem|ent));. |
|00004320| 20 20 20 69 66 20 28 4e | 65 77 2d 3e 6c 69 73 74 | if (N|ew->list|
|00004330| 5b 69 5d 20 3d 3d 20 4e | 55 4c 4c 29 0d 20 20 20 |[i] == N|ULL). |
|00004340| 20 20 20 4d 41 45 72 72 | 6f 72 28 22 62 6c 6f 62 | MAErr|or("blob|
|00004350| 20 64 61 74 61 22 29 3b | 0d 20 20 20 20 6d 65 6d | data");|. mem|
|00004360| 63 70 79 28 4e 65 77 2d | 3e 6c 69 73 74 5b 69 5d |cpy(New-|>list[i]|
|00004370| 2c 20 28 28 42 4c 4f 42 | 20 2a 29 4f 62 6a 65 63 |, ((BLOB| *)Objec|
|00004380| 74 29 2d 3e 6c 69 73 74 | 5b 69 5d 2c 20 73 69 7a |t)->list|[i], siz|
|00004390| 65 6f 66 28 42 6c 6f 62 | 5f 45 6c 65 6d 65 6e 74 |eof(Blob|_Element|
|000043a0| 29 29 3b 0d 20 20 20 20 | 7d 0d 0d 20 20 4e 65 77 |));. |}.. New|
|000043b0| 2d 3e 69 6e 74 65 72 76 | 61 6c 73 20 3d 20 28 42 |->interv|als = (B|
|000043c0| 6c 6f 62 5f 49 6e 74 65 | 72 76 61 6c 20 2a 29 6d |lob_Inte|rval *)m|
|000043d0| 61 6c 6c 6f 63 28 32 2a | 4e 65 77 2d 3e 63 6f 75 |alloc(2*|New->cou|
|000043e0| 6e 74 2a 73 69 7a 65 6f | 66 28 42 6c 6f 62 5f 49 |nt*sizeo|f(Blob_I|
|000043f0| 6e 74 65 72 76 61 6c 29 | 29 3b 0d 20 20 69 66 20 |nterval)|);. if |
|00004400| 28 4e 65 77 2d 3e 69 6e | 74 65 72 76 61 6c 73 20 |(New->in|tervals |
|00004410| 3d 3d 20 4e 55 4c 4c 29 | 0d 20 20 20 20 4d 41 45 |== NULL)|. MAE|
|00004420| 72 72 6f 72 28 22 62 6c | 6f 62 20 64 61 74 61 22 |rror("bl|ob data"|
|00004430| 29 3b 0d 0d 20 20 72 65 | 74 75 72 6e 20 28 4e 65 |);.. re|turn (Ne|
|00004440| 77 29 3b 0d 20 20 7d 0d | 0d 2f 2a 20 41 6c 6c 6f |w);. }.|./* Allo|
|00004450| 63 61 74 65 20 61 20 62 | 6c 6f 62 2e 20 2a 2f 0d |cate a b|lob. */.|
|00004460| 42 4c 4f 42 20 2a 43 72 | 65 61 74 65 5f 42 6c 6f |BLOB *Cr|eate_Blo|
|00004470| 62 28 29 0d 20 20 7b 0d | 20 20 42 4c 4f 42 20 2a |b(). {.| BLOB *|
|00004480| 4e 65 77 3b 0d 0d 20 20 | 69 66 20 28 28 4e 65 77 |New;.. |if ((New|
|00004490| 20 3d 20 28 42 4c 4f 42 | 20 2a 29 20 6d 61 6c 6c | = (BLOB| *) mall|
|000044a0| 6f 63 20 28 73 69 7a 65 | 6f 66 20 28 42 4c 4f 42 |oc (size|of (BLOB|
|000044b0| 29 29 29 20 3d 3d 20 4e | 55 4c 4c 29 0d 20 20 20 |))) == N|ULL). |
|000044c0| 20 4d 41 45 72 72 6f 72 | 20 28 22 62 6c 6f 62 22 | MAError| ("blob"|
|000044d0| 29 3b 0d 0d 20 20 49 4e | 49 54 5f 4f 42 4a 45 43 |);.. IN|IT_OBJEC|
|000044e0| 54 5f 46 49 45 4c 44 53 | 28 4e 65 77 2c 20 42 4c |T_FIELDS|(New, BL|
|000044f0| 4f 42 5f 4f 42 4a 45 43 | 54 2c 20 26 42 6c 6f 62 |OB_OBJEC|T, &Blob|
|00004500| 5f 4d 65 74 68 6f 64 73 | 29 0d 0d 20 20 20 20 4e |_Methods|).. N|
|00004510| 65 77 2d 3e 54 72 61 6e | 73 20 3d 20 4e 55 4c 4c |ew->Tran|s = NULL|
|00004520| 3b 0d 20 20 4e 65 77 2d | 3e 49 6e 76 65 72 74 65 |;. New-|>Inverte|
|00004530| 64 20 3d 20 46 41 4c 53 | 45 3b 0d 20 20 4e 65 77 |d = FALS|E;. New|
|00004540| 2d 3e 63 6f 75 6e 74 20 | 3d 20 30 3b 0d 20 20 4e |->count |= 0;. N|
|00004550| 65 77 2d 3e 74 68 72 65 | 73 68 6f 6c 64 20 3d 20 |ew->thre|shold = |
|00004560| 30 2e 30 3b 0d 20 20 4e | 65 77 2d 3e 6c 69 73 74 |0.0;. N|ew->list|
|00004570| 20 3d 20 4e 55 4c 4c 3b | 0d 20 20 4e 65 77 2d 3e | = NULL;|. New->|
|00004580| 69 6e 74 65 72 76 61 6c | 73 20 3d 20 4e 55 4c 4c |interval|s = NULL|
|00004590| 3b 0d 20 20 4e 65 77 2d | 3e 53 74 75 72 6d 5f 46 |;. New-|>Sturm_F|
|000045a0| 6c 61 67 20 3d 20 46 41 | 4c 53 45 3b 0d 0d 20 20 |lag = FA|LSE;.. |
|000045b0| 72 65 74 75 72 6e 20 28 | 4e 65 77 29 3b 0d 20 20 |return (|New);. |
|000045c0| 7d 0d 0d 76 6f 69 64 20 | 44 65 73 74 72 6f 79 5f |}..void |Destroy_|
|000045d0| 42 6c 6f 62 20 28 4f 62 | 6a 65 63 74 29 0d 4f 42 |Blob (Ob|ject).OB|
|000045e0| 4a 45 43 54 20 2a 4f 62 | 6a 65 63 74 3b 0d 20 20 |JECT *Ob|ject;. |
|000045f0| 7b 0d 20 20 75 6e 73 69 | 67 6e 65 64 20 69 3b 0d |{. unsi|gned i;.|
|00004600| 0d 20 20 44 65 73 74 72 | 6f 79 5f 54 72 61 6e 73 |. Destr|oy_Trans|
|00004610| 66 6f 72 6d 28 28 28 42 | 4c 4f 42 20 2a 29 4f 62 |form(((B|LOB *)Ob|
|00004620| 6a 65 63 74 29 2d 3e 54 | 72 61 6e 73 29 3b 0d 20 |ject)->T|rans);. |
|00004630| 20 66 6f 72 20 28 69 3d | 30 3b 69 20 3c 20 28 75 | for (i=|0;i < (u|
|00004640| 6e 73 69 67 6e 65 64 29 | 28 28 42 4c 4f 42 20 2a |nsigned)|((BLOB *|
|00004650| 29 4f 62 6a 65 63 74 29 | 2d 3e 63 6f 75 6e 74 3b |)Object)|->count;|
|00004660| 69 2b 2b 29 0d 20 20 20 | 20 66 72 65 65 20 28 28 |i++). | free ((|
|00004670| 28 42 4c 4f 42 20 2a 29 | 4f 62 6a 65 63 74 29 2d |(BLOB *)|Object)-|
|00004680| 3e 6c 69 73 74 5b 69 5d | 29 3b 0d 20 20 66 72 65 |>list[i]|);. fre|
|00004690| 65 20 28 28 28 42 4c 4f | 42 20 2a 29 4f 62 6a 65 |e (((BLO|B *)Obje|
|000046a0| 63 74 29 2d 3e 6c 69 73 | 74 29 3b 0d 20 20 66 72 |ct)->lis|t);. fr|
|000046b0| 65 65 20 28 28 28 42 4c | 4f 42 20 2a 29 4f 62 6a |ee (((BL|OB *)Obj|
|000046c0| 65 63 74 29 2d 3e 69 6e | 74 65 72 76 61 6c 73 29 |ect)->in|tervals)|
|000046d0| 3b 0d 20 20 66 72 65 65 | 20 28 4f 62 6a 65 63 74 |;. free| (Object|
|000046e0| 29 3b 0d 20 20 7d 0d 00 | 00 00 00 00 00 00 00 00 |);. }..|........|
|000046f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004700| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00004710| 00 00 00 00 00 00 0b f2 | 00 01 ec fc 00 00 00 00 |........|........|
|00004720| 00 00 1c 3c 00 01 f9 2e | 00 00 00 00 00 00 11 76 |...<....|.......v|
|00004730| 06 42 4c 4f 42 2e 43 da | 02 00 00 00 54 45 58 54 |.BLOB.C.|....TEXT|
|00004740| 4d 50 53 20 01 08 ff ff | ff ff 00 00 00 00 16 92 |MPS ....|........|
|00004750| 00 00 54 45 58 54 4d 50 | 53 20 01 08 ff ff ff ff |..TEXTMP|S ......|
|00004760| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004770| 00 00 a8 8d b2 ec 00 00 | 46 67 00 00 01 ac 00 00 |........|Fg......|
|00004780| 00 00 07 18 00 02 a8 dc | 00 00 00 00 00 00 16 1c |........|........|
|00004790| 00 02 b0 0c 00 00 00 00 | 00 00 0a 1c 00 02 c6 68 |........|.......h|
|000047a0| 00 00 00 00 00 00 23 de | 00 02 d0 98 00 00 00 00 |......#.|........|
|000047b0| 00 00 14 36 00 02 f4 9a | 00 00 00 00 00 00 0b 4e |...6....|.......N|
|000047c0| 00 03 08 f4 00 00 00 00 | ff ff ff fc 00 03 14 46 |........|.......F|
|000047d0| 00 00 00 00 ff ff ff fc | 00 03 14 46 00 00 00 00 |........|...F....|
|000047e0| ff ff ff fc 00 03 14 46 | 00 00 00 00 ff ff ff fc |.......F|........|
|000047f0| 00 03 14 46 00 00 00 00 | 00 00 0c 0e 00 03 14 5a |...F....|.......Z|
|00004800| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 00 01 54 |...H..Mo|naco...T|
|00004810| 00 02 57 00 00 0a 00 02 | 01 b9 00 11 01 d5 00 00 |..W.....|........|
|00004820| 00 00 00 00 00 00 00 06 | 00 04 00 64 00 1c 01 dd |........|...d....|
|00004830| 02 3d 00 64 00 1c 01 dd | 02 3d a8 8d b2 ec 00 00 |.=.d....|.=......|
|00004840| 00 00 00 00 00 00 00 00 | 00 00 01 00 00 00 00 1e |........|........|
|00004850| 00 64 00 1c 01 dd 02 3d | 00 64 00 1c 01 dd 02 3d |.d.....=|.d.....=|
|00004860| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004870| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 8d |.....n..|.n...>..|
|00004880| 3b f8 18 3e 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |;..>....|.>..MPSR|
|00004890| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|000048a0| 03 f0 ff ff 00 00 00 4c | 00 8f 92 c8 00 00 00 00 |.......L|........|
|000048b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+